Step by Step

Monday, May 23, 2011

To be able to style an element on a page, a browser has to know three things [Part 2]

4-The Class Selector
Style multiple HTML elements through the class attribute. This is handy when you want to give the same type of formatting to a number of unrelated HTML elements.
.Highlight
{
font-weight: bold;
color: Red;
}
The class attribute can be reused a piece of CSS for many different purposes, regardless of the HTML element that uses the class.

Grouping and Combining Selectors

CSS also enables you to group multiple selectors by separating them with a comma. This is handy if you want to apply the same styles to different elements. The following rule turns all headings in the page to red:
h1, h2, h3, h4, h5, h6
{
color: Red;
}

0 comments: