HTML Anchor Tags

You often see links that point to a specific part of a page. Those are called anchor links. If you have a specially long page, you might want to split it up into different sections and add links that scroll to different parts of it.

Insert the HTML Anchor Tags

First, you need to insert the anchor. This is the the place where the link will land. The HTML tag to insert the anchor is <a name="anchor name">referenced text</a>. Replace "anchor name" with a name you will remember when linking to the anchor. Replace the referenced text with the heading of the section you are linking to. You can put extra HTML in there like heading tags or styling tags. Note that the referenced text will appear on screen. The anchor name will not.

Linking to the Anchor

The code to link to HTML anchor tags is <a href="#anchor name">Clickable Text</a>. Linking to anchors is the same thing as linking to any file or website. If the destination of the link is in another page of your website, use <a href="page.html#anchor name">Clickable Text</a>

Here's an example of an anchor and a link to it:

<html>
<head>
<title>html anchor tags</title>
</head>
<body>
<a name="anchor1">Heading of computing4all.com</a>
<a href="#anchor1">Click here to go to the top of the page</a>
</body>
</html>

Back
HTML Code For Links
Next
Add a List in HTML