Sometimes you want to change the appearance of certain
elements on your page using a CSS stylesheet (see Section 5, “Separating content and presentation with CSS”). To do this, invent a name for those
elements; this name must conform to the rules for names
discussed in Section 6.2, “The ID datatype”. Then, add a
class attribute to those elements.
For example, suppose several paragraphs on your pages are
important warnings, and you want to print them in larger
type with a red border. To do this, add an attribute
“class='warning'” to each
paragraph. Then, your CSS stylesheet would use the
selector p.warning with a rule that
specifies larger type and a red border.
Any number of elements can have the same value of their
class attributes, unlike id
values which must be unique within a document (see Section 15.4, “The id attribute: Assigning a unique
identifier to an element”).
An element can actually belong to several classes. In
that case, use a class attribute whose
value is a list of its classes separated by spaces. For
example, the start-tag <ul class="info Kyzyl
Feynman" would mean that the ul
element is a member of three different classes.