HTML » HTML Core Attributes » class

Version: 4.0

Syntax:
class="name"

The class core attribute is used to assign the name of a style sheets class to a tag.

For example, all of the code samples on the DevGuru site are in blue colored text. This is done by enclosing the code sample inside a pair of span tag elements and designating a class of "CODE". In turn, the "CODE" class has been assigned a text color of blue in the style sheets file (a .css file) that is located in the Include/ directory on the DevGuru web site. (Thus, only one file is needed to define the appearance of the entire site.)

Examples

Code:
<span class="CODE">
The code example is blue.
</span>
Output:
The code example is blue.
Explanation:

This example demonstrates how DevGuru uses the span tag to make their code be displayed in a blue font color.

Language(s): HTML
Code:
<font class="CODE">
This text is blue.
</font>
This text is not blue.
Output:
This text is blue.
This text is not blue.
Explanation:

The exact same effect can be accomplished using other permitted tags.

Language(s): HTML