Since nearly the start of the HyperText Markup Language (HTML) as used online, HTML anchors have remained one of the core interactive elements used in nearly all web pages. HTML anchors are a type of tag represented by the letter "A" that allows a user to click on an element and either be taken to a universal resource location (URL) such as another web page or to a different section within the same HTML document. It is more common to refer to HTML anchors as links or hyperlinks. Similar to many other HTML tags, anchors are able to be customized with both standard HTML formatting properties and cascading style sheet (CSS) extensions.
Within a web page, HTML anchors are used to move a user from one page to another, or to other marked locations within the same page. The anchor is represented by the letter "A" at the start of the tag. When moving between web pages, the address of the destination URL is assigned to the hypertext reference (href) property, although this also can be an image, a program or nearly any type of content. The default behavior of an anchor is to open the new URL in the same browser window, replacing the current content, although this behavior can be changed to open URLs in new windows or in targeted frames on a page.
The second use for HTML anchors is either to define or move to sections of the HTML document being viewed. By assigning a name to the anchor tag through the name property, an anchor is created in the document that can be referenced elsewhere. Just like moving to another web page, the anchor tag can be used to move to an anchor on the same page once it is defined, allowing for a table of contents or indexes to be created.
When using HTML anchors, the tag itself has no visual representation, but instead needs to enclose whatever visual elements will be used to represent it. The anchor tag can wrap around text, images or entire formatted blocks. By default, visual HTML elements that are surrounded by anchor tags are underlined and colored differently, depending on whether the link was visited by the user. Anchor text also changes color when a mouse hovers over it, although again this can be changed.
The use of HTML anchors to define locations within a single document has been depreciated and should not be used except to maintain legacy code. Instead, anchor locations within a document should be defined by assigning an identification (ID) through CSS to block level tags, such as headings. The anchor tag can, however, still be used to jump to these locations though a link.