In CSS, the class selector is displayed with a point number:
. Center {Text-align:center}
In the above example, all HTML elements that have the center class are centered.
In the following HTML code, the H1 and P elements all have the center class. This means that both will comply with the rules in the. Center selector.
<H1 class= "center" > This heading'll be center-aligned
*****************************
ID Selector
The ID selector can specify a specific style for HTML elements marked with a specific ID. The ID selector is defined with "#". The following two ID selectors, the first one to define the color of the element is red, and 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 attribute of red is displayed in red, and a P element with the ID property is green.
<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. Do you want to know why, see XHTML: Web site refactoring.