HTML and CSS Reference
In-Depth Information
Generic classes are quite handy and make it easy to apply a particular
style to a broad range of tags. All the popular browsers support CSS2
generic classes.
8.3.3. ID Classes
Almost all HTML tags accept the id attribute, which assigns a unique
identifier to an element within the document. Besides being the target
of a URL or identified in an automated document-processing tool, the id
attribute can also specify a style rule for the element.
To create a style class that the styles-conscious browser applies to only
those portions of your document explicitly tagged with the id attribute,
follow the same syntax as for style classes, except with a # character
before the class name instead of a period. For example:
#yellow {color : yellow}
h1#blue {color : blue}
Within your document, use that same id name to apply the style, such
as <h1 id=blue> to create a blue heading. Or, as in the example, use
id=yellow elsewhere in the document to turn a tag's contents yellow.
You can mix and match both class and id attributes, giving you a lim-
ited ability to apply two independent style rules to a single element.
There is a dramatic drawback to using style classes this way: the HTML
and XHTML standards dictate that the value of the id attribute be unique
for each instance in which it's used within the document. Yet here, we
have to use the same value to apply the style class more than once.
Search WWH ::

Custom Search