You can give your (X)HTML elements either a unique name or one that identifies them as belonging to a particular class. You can then apply styles to all elements with a given name.
To name unique elements:
Within the opening tag of the element, type id="name", where name uniquely identifies the element.
To name groups of elements:
Within the opening tag of the element, type class="name", where name is the identifying name of the class.
Figure 3.14. Add an id attribute to a unique element in order to identify it for later formatting or links. Add a class attribute to a group of elements to be able to format them all in one fell swoop.
Figure 3.15. The id and class attributes do not by themselves modify an element's appearance. They must be combined with CSS formatting to show their full strength (as described in Chapters 10 and 11).
Each id in an (X)HTML document must be unique. In other words, no two elements can be named with the same id.
More than one element may belong to, and thus be marked with, the same class.
For information about applying styles to an element with a particular id or class, consult Selecting Elements by ID or Class on page 140.
The class and id attributes may be added to most (X)HTML elements but are particularly useful with the div and span elements (see pages 6465).
The id attribute automatically turns the element into an anchor, to which you can direct a link. For more details, consult Creating Anchors on page 106.