HTML and CSS Reference
In-Depth Information
Linking to Specific Places Within
Documents
The links you've created so far in this lesson have been from one point in a page to
another page. But what if, rather than linking to that second page in general, you want to
link to a specific place within that pageā€”for example, to the fourth major section down?
You can do so in HTML by creating an anchor within the second page. The anchor cre-
ates a special element that you can link to inside the page. The link you create in the first
page will contain both the name of the file to which you're linking and the name of that
anchor. Then, when you follow the link with your browser, the browser will load the sec-
ond page and then scroll down to the location of the anchor. (Figure 6.10 shows an
example.)
FIGURE 6.10
Links and anchors.
softfruits.html
berries.html
Soft Fruits
Blackberries
Blackberries grow on canes
Please choose a subtopic:
*Strawberries
*Cane Fruits:
Blueberries
Blueberries grow on bushes
in colder climates
*Blackberries
*Raspberries
*Loganberries
Strawberries
*Bush Fruits:
Strawberries are an
herbaceous plant
*Blueberries
*Huckleberries
Anchors are special places that you can link to inside documents. Links can then jump to
those special places inside the page as opposed to jumping just to the top of the page.
You can use links and anchors within the same page so that if you select one of those
links, you jump to a different anchor within the page. For example, if you create an
anchor at the top of a page, you could add links after each section of the page that return
the user to the top. You could also create anchors at the beginning of each section and
include a table of contents at the top of the page that has links to the sections.
6
Creating Links and Anchors
You create an anchor in nearly the same way that you create a link: by using the <a> tag.
If you wondered why the link tag uses an <a> rather than an <l> , now you know: a actu-
ally stands for anchor .
 
 
Search WWH ::




Custom Search