Apart from styles for a HTML tag CSS aslo allows us to specify our own selectors called "id" and "class".
ID SELECTOR:
The id selector is used to specify a style for a single and unique element. The id selector uses id attribute of HTML-element and it's defined with a #.
#ID1
{
text-align:right;
color:blue;
}
CLASS SELECTOR:
Class selector is used to specify a style for a group of HTML elements. Class selector is most often used on several HTML elements. This allows you to set a particular style for any HTML elements with the same class.
The class selector uses the HTML class attribute, and is defined with a "."
A.left
{
text-align:left;
}
According to the line above all A elements with class="left" will be left aligned.
NOTE: Ids/Calsses does not work in Mozilla/Firefox if their names start with a number.
No comments:
Post a Comment