In CSS, the class selector is displayed with a dot number:
. Center {Text-align:center}
In the example above, all HTML elements that have the center class are centered.
In the following HTML code, both the H1 and P elements have the center class. This means that both will adhere to the rules in the. Center selector.
<H1 class= "center" > This heading would be a center-aligned
*****************************
ID Selector
The ID selector can specify a specific style for an HTML element that is labeled with a specific ID. The ID selector is defined as "#". The following two ID selectors, the first one can define the color of the element to be red, the second defines the color of the element as green:
#red {color:red;} #green {color:green;}
In the following HTML code, the P element with the ID property of red is shown in red, and the P element with the id attribute green is shown in the blue.
<p id= "Red" > This paragraph is red. </p> <p id= "Green" > This paragraph is greenish. </p>
Note: The id attribute can only appear once in each HTML document. Want to know why, see XHTML: Site refactoring.