HTML and CSS Reference
In-Depth Information
Linking to an id
Once you've marked an element using the id attribute, you can create a hypertext link to
that element using the a element
<a href=”# id ”> content </a>
where id is the value of the id attribute of the element. For example, to create a link
to the h2 heading for the letter A in the glossary document, you would enter the follow-
ing code:
<a href=”#A”>A</a>
You'll change each entry on the Glossary page to a hypertext link pointing to the sec-
tion of the glossary corresponding to the selected letter.
To change the list of letters to hypertext links:
1. Locate the letter A in the list of letters at the top of the glossary.htm file.
2. After the [ character, insert the following opening tag:
<a href=”#A”>
3. Between the letter A and the ] character, insert the closing </a> tag. Figure 2-21
shows the revised code.
Figure 2-21
Marking a hypertext link for “A”
linking "A" to t he
element with the id A
Make sure you include
the pound symbol (#) in
the hypertext link, and
ensure that the id text
matches both upper- and
lowercase letters in the
linked id.
4. Mark the letters B through F in the list as hypertext links pointing to the appropri-
ate h2 headings in the document. Figure 2-22 shows the revised code for the list
of letters.
Figure 2-22
Hypertext links for the list of letters
Gerry also wants you to create a hypertext link at the bottom of the file that points
to the top. You'll use the id attribute you created in the last set of steps.
Search WWH ::

Custom Search