Pages

CSS class

A style could be applied not only to a specific HTML tag, but also to a class. We can create a style for a couple tag/style or just for a class. In the last case all the tags referencing to that class would use that style.

To mark that a specific tag should conform to a specific style class, we set for it the attribute class with the required value. So, this paragraph would use the style defined for the green class:
<p class="green">A smooth, mild blend of coffees from Mexico, Bolivia and Guatemala.</p>
In the CSS file we define a style for a tag in this way:
p.green { color: green; }
We can define a class style that could be used by all tags:
.brown { color: brown; }
In this case we could use the brown style in each tag that supports the class attribute.

A fun book for HTML beginners: Head First HTML. If you are interested in CSS, go to chapter eight.

No comments:

Post a Comment