Home CSS Class Group with the Class Attribute
Search MS Office A-Z   |   Search Web Pages/ Design A-Z

Group with the Class Attribute

The CLASS attribute groups tags that are going to have a particular characteristic in common. The main use of the CLASS attribute is to relate a group of elements to style sheet rules. The CLASS attribute, like the ID attribute, associates a tag with a name. Unlike ID, however, you can use a particular CLASS value with different elements within the same document. In addition, you can use ID and CLASS together. In practice, this usage could look like this:

<HEAD>
<TITLE>ID, Class, Style, and Title</TITLE>
<STYLE type=”text/css”>
<!--
#InitialParagraph {color: #000080;}
.YellowHighlight {background-color: #ffffcc;}
-->>
</STYLE>
</HEAD>
<BODY>
<H3 ID=”InitialParagraph” CLASS=”YellowHighlight”>This small headline has a yellow background due to use of the CLASS attribute.</H3>
<P CLASS=”YellowHighlight”>This paragraph text has the background color.</P>
<P>This one doesn’t.</P>
</BODY>