Naming Elements
You can give your 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.
Tips
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 Class or ID on page 137.
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 6869).
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 120.
Finally, the id attribute can also be used to identify elements that will be affected by a scripting language, such as JavaScript.
Find extra tips, the source code for examples, and more at www.cookwood.com