HTML and CSS Reference
Use the <a> tag with its name attribute to identify a fragment. Here's a
sample fragment identifier:
<h3><a name="Section_7">Section 7</a></h3>
Alternatively, use the id attribute and embed the hyperlink target direc-
tly in a defining tag, such as a header: [*]
[*] We prefer the id way, although not all browsers support it, yet.
<h3 id="Section_7">Section 7</h3>
A hyperlink to the fragment is an <a> tag with the HRef attribute, in which
the attribute's valuethe target URLends with the fragment's name, pre-
ceded by the pound sign ( # ). A reference to the previous example's frag-
ment identifier, then, might look like this:
See <a href="index.html#Section_7">Section 7</a>
for further details.
By far, the most common use of fragment identifiers is in creating a
table of contents for a lengthy document. Begin by dividing your docu-
ment into several logical sections, using appropriate headers and con-
sistent formatting. At the start of each section, add a fragment identifier
for that section, typically as part of the section title. Finally, make a list
of links to those fragment identifiers at the beginning of your document.
Our sample document extolling the life and wonders of the mighty kum-
quat, for example, is quite long and involved, including many sections
and subsections of interest. It is a document to be read and read again.
In order to make it easy for kumquat lovers everywhere to find their
section of interest quickly, we've included fragment identifiers for each
major section and placed an ordered list of linksa hot-linked table of