You can create your own customized classes by adding the class attribute to your HTML tags. The syntax for creating a class is:
where tag is the HTML tag and class_name is the name of the class.
Once a class has been created, you can apply a style specific to that class with the declaration:
If the same class name is used for several different types of tags, you would omit the tag name from the style declaration, following the syntax
Example:
The file style.css used for this set of Web pages contains the following class definitions:
CSS classes |
---|
.ritem { color : #cc3366; font-weight : bold } .yello { background-color : lightyellow; vertical-align : top } |
The first class is used, for example, in the Class Outline Web page for displaying the titles for each part of the course. The second class is used, for example, for creating table rows with a lightyellow background:
HTML tags |
---|
<span class="ritem">Part 4: Working with Cascading Style Sheets</span> <td class="yello"> . . . </td> |