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="http://www.web4college.com">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="https://www.web4college.com" target="_blank">Here is text link</a>
Try</>

Image links

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

<a href="http://www.web4college.com"> <img src="/images/codingb-96x96.png"/> </a>
Try</>

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>
Try</>

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
href

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

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

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

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

It downloads the linked file instead of accessing the link.

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

defines the language of the linked resource.

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

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>
type

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?