What does the a tag do in HTML?
A tag a or anchor tag is an element used to create a hyperlink to another web page or to a bookmarked location on the same web page.
Tag a as an anchor link
An anchor hyperlink created by an href anchor attribute can be applied to text, images or other HTML content embedded within the a tag, with the anchor location specified via the name attribute.
<html> <head> <title>Tag a in HTML</title> </head> <body> <a href="#1">Tag a as an anchor link</a> <a href="#2">Tag a as an ordinary link</a> <a name="1"></a> <h2>Tag <a> as an anchor link</h2> paragraph text <a name="2"></a> <h2>Tag <a> as an ordinary link</h2> paragraph text </body> </html>
Tag a as ordinary link
A normal hyperlink, applied to the href attribute, uses a URL document address that points to a related document, resource, location to jump to.
<html> <head> <title>Tag a in HTML</title> </head> <body> <a href="https://domhtml.ru/en/">Check out our site</a> <h2>Tag <a> as an anchor link</h2> paragraph text <h2>Tag <a> as an ordinary link</h2> paragraph text </body> </html>
Attributes applied to tag a
|hreflang||defines the language of the text at the link|
|download||tells the browser to download the given file and not to open it|
|specifies the name of the context window in which the document will be loaded|
|title||text||specifies the title of the link, which is displayed to the user as a tooltip|
|href||url||specifies a related document, resource, or location to which you want to jump|
|name||defines the name of the anchor on the page or site to which the jump occurs|
As it appears from the above, hyperlink addresses can be relative and absolute. Relative (anchor) hyperlinks work within the current page or site. Absolute (normal) links allow you to jump to any address that is spelled out between the opening and closing a tags.