In the latest article we have seen how anchor tags can be used to link text and images to another document by creating a single hypertext-related link using the <a> tag (anchor tag).
In an HTML document, anchor tags are also used to create page sections that serve as a bookmark within a document. Such anchor tags take the readers to a particular section in a document. These anchor tags are referred to as named anchor tags since the HTML code includes user-created HTML names created within the document.
Anywhere in a document, you can specify a named anchor using the following HTML code:
Via the above code, a user can link to the specified section in a web page either from the same document or from another document:
To link to a specified section from the same document the following code is used:
<a href="#section">Link to section</a>
To link to a specified section within a document from another document, a normal link needs to be specified followed by a section:
<a href="../misc/page.html#section">Link to section in document</a>
Page sections are also used to create internal hyperlinks within a document. These codes in fact are often used to create a “Table of Contents" within a document which lends a professional look to documents along with ease of navigation. Such internal hyperlinks enable the user to move from one location to another within the same document.