The <a> element is a container element. This means you need an opening and closing <a> tag, as in the following example:
<a href="dest.html">See the destination</a>
Which can be split into sections as follows:
<a href="dest.html">
|
See the destination
|
</a> |
This tag starts “active text” for a link
with dest.html as the hypertext
reference.
|
This is the active text | And this closing tag marks the end of the clickable link |
The most common mistake is to forget that <a> is a container; people try to put everything into one tag:
<a href="dest.html" See the destination>
In the bad HTML tag below, the author remembered to use both an opening and closing tag, but didn’t put the link’s text between them. Since there’s nothing between the two tags, there won’t be any clickable text showing up on the screen.
<a href="dest.html"></a>See the destination
You don’t need any text between the opening and closing tags
when you’re defining an anchor with the
id=
attribute, since it’s just a marker. This is
another source of confusion for beginning authors.
When using a within-page link, people either leave out the # in the
href=
or add an extra one in the id=
attribute.
Too Few # | Too Many # |
---|---|
<a href="anchor">Jump</a> . . <a id="anchor"></a>(The first line should have a #) |
<a href="#anchor">Jump</a> . . <a id="#anchor"></a>(The last line should not have a #) |
<< The “Combo Link” | Index | Clickable Images >> |