When talking about HTML, an anchor or hyperlink anchor is an area within hypertext that contains the source or destination of a link that links to a different address or other information. In HTML, an anchor will begin with <a> and end with </a>, as shown in the breakdown of an HTML tag.
Working example of a hyperlink anchor
The example code below is an anchor that links to the Computer Hope web page, with the anchor being Computer Hope.
<a href="https://www.computerhope.com">Computer Hope</a>
When inserted into a web page, the code would generate the example below. In the example, "Computer Hope" is the anchor text in the anchor.
Alternatively referred to as a bookmark, a named anchor is an anchor that links to a location on a page. For example, "#top" is a named anchor that allows the reader to return to the top of the page. If they were at the bottom of the page, the browser window would scroll to the top when the link was clicked.
Named anchors are comprised of the HTML <a> tag with the href attribute pointing to another tag with the name or id attribute. For example, in our #top example, the anchor tag would like the code shown below.
<a href="#top">Back to Top</a>
- See our page on how to create links to sections on the same page in HTML for further information and examples.