HTML and CSS Reference
In-Depth Information
section unambiguously. Specifically, the value must begin with a letter,
and can contain letters, numbers, hyphens, colons, underscores, and
periods, but not spaces. Although we're introducing it within the context
of the
<div>
tag, this attribute can be used with almost any tag.
When used as an element label, the value of the
id
attribute can be ad-
ded to a URL to address the labeled element uniquely within the docu-
ment. You can label both large portions of content (via a tag like
<di-
v>
) and small snippets of text (using a tag like
<i>
or
<span>
). For ex-
ample, you might label the abstract of a technical report using
<div
id="abstract">
. A URL could jump right to that abstract by referencing
report.html#abstract
. When used in this manner, the value of the
id
at-
tribute must be unique with respect to all other
id
attributes within the
document and all the names defined by any
<a>
tags with the
name
at-
tribute. [
Linking Within a Document, 6.3.3
]
When used as a stylesheet selector, the value of the
id
attribute is the
name of a style rule that can be associated with the current tag. This
provides a second set of definable style rules, similar to the various style
classes you may create. A tag can use both the
class
and the
id
attrib-
utes to apply two different rules to a single tag. In this case, the name
associated with the
id
attribute must be unique with respect to all other
style IDs within the current document. You can find a more complete
4.1.1.5. The title attribute
Use the optional
title
attribute and quote-enclosed string value to as-
sociate a descriptive phrase with the division. Like the
id
attribute, the
title
attribute can be used with almost any tag and behaves similarly
for all tags.
There is no standards-defined usage for the value of the
title
attribute,
but current browsers display the title when the mouse pauses over that
elementin this case, anywhere in the
<div>
-defined text area. For ex-