Home Advertise with us Forum Articles Sitemap Contact
Logo  

CSS Selectors

Selectors form the very base of Cascading Style Sheets or CSS. Selectors are nothing but simply names that you provide for the different HTML elements that you wish to style like, heading paragraph, etc.

The CSS syntax consists of two major parts – the selector & one or more declarations. Each declaration part consists of a property & a value, where the property is actually the style attribute you wish to change along with its value. This can be better explained as follows:
Syntax: SELECTOR {PROPERTY: VALUE}

Example: p {color:green; font-size:15px;}

Explanation :
  • Here p is the paragraph HTML element also called the "selector" that is to be styled.

  • In the declaration part, color is the "property" with the "value" green & font-size is yet another property with the value 15px.

Once created, the above example will serve as a template that can be used every time you plan to manipulate the paragraph HTML element. Find below a complete example of the way these CSS selectors are defined in HTML.

Example:

Code Results

<html>

<head>

<style type="text/css">

B.headline {color:blue; font-size:15px;
font-family:calibri;}

</style>

</head>

<body>

<b class="headline">This is headline style bold</b>

<body>
<html>

This is headline style bold