In CSS, class selectors are displayed with a period:
.center {text-align: center}
In the above example, all HTML elements with the center class are centered.
In the following HTML code, both h1 and p elements have the center class. This means that both will respect the rules in the ".center" selector.
<h1 class="center"> This heading will be center-aligned </h1> <p class="center"> This paragraph will also be center-aligned. </p>
*******************************
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 can define the color of the element as red, and the second one can define 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 red is displayed in red, and the p element with the id attribute green is displayed in green.
<p id="red">This paragraph is red. </p> <p id="green">This paragraph is green. </p>
Note: The id attribute can appear only once in each HTML document. To find out why, see XHTML: Website Refactoring.