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>|
<a href="" target="_blank">Go to google</a>

Try </>

target attribute represents the browsing mode of link i.e. whether the link should be browsed in the same window or new window.

Specific Use

Text links

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


<a href="" 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=""> <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.

Related tags

<br>It breaks a line into multiple lines.
<p>The paragraph line breaks at <br> element.</p>

Tag omission

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

Global Attributes

All the global attributes are applicable on a element.

Specific Attributes

<a> tag attributes

hrefThis 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" rel="next">...</a>
type represents the type of link. For HTML file,
<a href="test.html" type="text/html">..</a>

Was this article helpful?




Get the newsletter