HTML and CSS Reference
In-Depth Information
element—such as a heading or paragraph—always put the anchor inside the element. In
other words, enter
<h2><a name=”byrd”> Byrd, William, 1543-1623 </a></h2>
but do not enter
<a name=”byrd”><h2> Byrd, William, 1543-1623 </h2></a>
The second example can confuse your browser. Is it an anchor, formatted just like the
text before it, with mysteriously placed heading tags? Or is it a heading that also happens
to be an anchor? If you use the right code in your HTML file, with the anchor inside the
heading, you avoid the confusion. The easiest answer is probably just putting the anchor
ahead of the heading tag, like this:
<a name=”byrd”></a>
<h2>Byrd, William, 1543-1623</h2>
So, you've added your anchor to the heading and its name is “byrd” . Now go back to the
See Also line in your m.html file:
<p><em> See Also </em>
Byrd, Gibbons, Lassus, Monteverdi, Morley, Weelkes, Wilbye </p>
You're going to create your link here around the word Byrd , just as you would for any
other link. But what's the URL? As you learned previously, pathnames to anchors look
similar to the following:
page_name#anchor_name
If you're creating a link to the b.html page, the href is as follows:
<a href=”b.html”>
Because you're linking to a section inside that page, add the anchor name to link that
section so that it looks like this:
<a href=”b.html#byrd”>
Note the small b in byrd . Anchor names and links are case-sensitive; if you put #Byrd in
your href , the link might not work properly. Make sure that the anchor name you use in
the name attribute and the anchor name in the link after the # are identical.
Search WWH ::




Custom Search