XHTML » XHTML Core Tag » class

Syntax:
class="name"

The class attribute is used to assign the name of a style sheet 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. Therefore, only one file is needed to define the appearance of the entire site.
 
There are four attributes common to most tags: class, id, style, and title.
 

Examples

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DevGuru XHTML class Attribute Example</title>
</head>
<body>
<span class="CODE">
The code example is blue.
</span>
</body>
</html>
Output:
The code example is blue.
Language(s): XHTML