HTML a tag

HTML <a> tag defines hyperlink. hyperlink is the hypertext anchor that points the source (text link) to the destination source (other page or website). We can make a link to other websites or other web pages.

<a href="">Go to web4college</a>

Tag Uses

Specific uses of <a> tag

Text links

Text links are made by writting the text inside the <a> tags.

<a href="" target="_blank">Here is text link</a>

Image links

Image links can be made by placing the image inside the <a> tags.

<a href=""> <img src="/images/codingb-96x96.png"/> </a>

Email links

Email links are also possible. The email link directs the user to the respective email address.

<p>Email to: <a href="mailto:[email protected]" target="_blank">Becky.</a>

Tag omission

Both opening and closing tags are necessary for the a element.

Global Attributes

All the global attributes are applicable on a element.

Tag Attributes

Attributes that are applicable to <a> tag

This attribute contains the address or URL of the other pages.

<a href="address of external resource/URL">anchor text</a>

It represents the browsing mode. By default, the link opens in the current window.

<a href="url" target="_blank">anchored text</a>

It downloads the linked file instead of accessing the link.

<a href="test.html" download>...</a>

defines the language of the linked resource.

<a href="test.html" hreflang="en-US">...</a>

rel attribute defines the type of relation between the current document and the destination source. For example, for the next page link.

<a href="test.html" hreflang="en-US">...</a>

represents the type of link. For HTML file,

<a href="test.html" type="text/html">..</a>

<br> tag breaks a line into multiple lines.

Was this article helpful?