HTML <a> Tag: The <a> specifies a hyperlink. It is used to link one page with the other. The href attribute is the important attribute in <a> tag, it defines the link’s destination. By default, links will appear as follows in all browsers as follows:
- An unvisited link is underlined and blue
- A visited link is underlined and purple
- An active link is underlined and red
HTML <a> Tag
In HTML 4.01 the <a> tag can be either a hyperlink or anchor whereas in HTML5 tag is always a hyperlink.
Syntax: <a href = “link”> Link Name <a>
This tag supports different types of attributes. They are as follows:
charset: This attribute is used to specifies the character-set. It is not supported by HTML 5.
download: It is used to specify the target link to download when the user clicks.
hreflang: It is used to specify the language of a linked document.
media: It is used to specify the linked media.
coords: It is used to specify the coordinate of links.
name: It is used to specify the anchor name.
rel: It is used to specify the relation between the current document and the linked document.
shape: It is used to specify the shape of the link.
type: It is used to specify the type of links.
target: It specifies the target link.
rev: It is used to specify the relation between the linked document and the current document.
Browser compatibility
The <a> tag is supported by different types of browsers. They are as follows:
- Chrome
- Firefox
- Safari
- InternetExplorer
- Opera browsers.
Example:
<!DOCTYPE html> <html> <body> <a href="https://tutorials.freshersnow.com">Welcome to Freshersnow Tutorial!!</a> </body> </html>
Output:
Welcome to Freshersnow Tutorial!!
Attributes that are supported by the <a> tag
Attribute | Value | Description |
---|---|---|
charset | char_encoding | specifies the character set of a linked document |
coords | coordinates | Specifies the coordinates of a link |
href | URL | Specifies the URL of the page the link goes to |
hreflang | language_codeload | Specifies the language of the linked document |
name | section_name | Specifies the name of an anchor |
onSelect | select | When the user selects the form input field |
ping | list_of_URL | Specifies a space-separated list of URLs to which, when the link is followed, post requests with the body ping will be sent by the browser. It is used for tracking. |
target | _blank _parent _self _top frame name |
Specifies where to open the linked document |
type | media_type | Specifies the media type of the linked document |
rev | text | Specifies the relationship between the linked document and the current document |
shape | default rect circle poly |
Specifies the shape of a link |