Saturday, December 10, 2011

CSS Id and Class


The id selector
The id selector is used to specify a style for a single, unique element. The id selector uses the id attribute of the HTML element, and is defined with a “#”. And the style rule below will be applied to the element with id=”paral”;
Example:
# paral{text-align:center;color:red;}
The class selector
The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements. This allows you to set a particular style for many HTML elements with the same class. The class selector uses the HTML Class attribute, and is defined with a. In the example below, all HTML elements with class=”center” will be center –aligned;
Example:
.center{text-align:center;}
  

No comments:

Post a Comment