Now that you know how to link to other resources, you might want your hyperlinks to be more meaningful. HTML enables you to use hyperlinks to point to a specific spot (or anchor) in an HTML document, instead of just pointing to the entire document. As an example, suppose that you have a list of headlines at the top of your HTML document that points to a more complete article at the bottom of your document. This is easy in HTML. Remember that anchor tags come with three attributes: HRef (which has already been discussed), and name and id (which always appear together). Anchor
Caution
The <a> tag also enables you to name an anchor (or bookmark) in your document with the name and id attributes. HTML then enables you to use the anchor tag to point directly to that bookmark. Figure 4.1 demonstrates how the example in the previous paragraph might look in HTML. Figure 4.2 shows that same document in the browser. Figure 4.1. Notice how the href attribute points to the location named by the name and id attributes.Figure 4.2. The <a> tag with the HRef attribute is highlighted, but the <a> tag with the name and id attributes is not.Caution
Tip
Linking to an Anchor in Another PageCreating a hyperlink to an anchor in another page requires only one more element: the URL. As you learned before, you can link to an anchor in a file on your own Web site, as shown in Figure 4.3, or you can link to a known anchor in a file on another Web site. The keyword in that sentence is known. You can't link to a specific spot on a file unless that spot is already recognized by the Web browser as a named anchor. Figure 4.3. Notice that each href attribute includes a folder name (articles), a filename (colors.htm), and the specific anchor name (red).Tip
Table 4.1 lists the HTML tags that were discussed in this lesson.
In this lesson, you've learned:
|