How to use a Tag HTML and Attributes used in Anchor Tag

How to use <a> Tag HTML and Attributes used in Anchor Tag

anchor tag html | How to use Anchor tag



Today we’ll be taking a look at the anchor tag which is one of the most used tags in web development.

It is crucial to understand the anchor tag completely before getting into the actual coding part. The Anchor tag <a> along with its ‘href’ i.e. “Hyper REFerence” attribute is used to link webpages, locations, emails, etc.

50+ HTML, CSS & JavaScript Projects With Source Code

Given below is an example of an anchor tag :

While using anchor tag attributes plays an important role, let us take a closer look at the attributes which are used in anchor tags.

Attributes used in Anchor Tag

1. a Href  Attributes used in Anchor Tag

The href attribute is like the default attribute to redirect to another webpage when the word between the anchor tag is clicked.


<a href="URL"></a>


Href attribute can be used to  

  1. the point at different sections on the same webpage.
  2. link different web pages.
  3. create a call link with “tel”
  4. create a mail link with “mailto”

2. Download Attributes used in Anchor Tag

The download attribute is used to download the specified file linked in the href Attribute.

Responsive Gym Website Using HTML ,CSS & JavaScript


<a href="URL" download="filename">download</a>

The value passed in the download attribute i.e “filename” will be used as the name of the file which will be downloaded.

E.g. :

3.Hreflang Attributes used in Anchor Tag

Hreflang attribute is used to specify the language of the linked page in the href attribute.


<a href="URL" hreflang="lang_code"></a>

NOTE: The language code is a two-letter code used to identify the languages.
The Hreflang can only be used when the Href attribute is defined.

100+ JavaScript Projects With Source Code ( Beginners to Advanced)

4. Target Attributes used in Anchor Tag

The Target attribute specifies how to open the linked webpage.
<a href=”URL” target=”_blank”></a>
By default, the value of the target attribute is set to “_self”.
Following are the values used in the target attribute and what are they used for:


  • _self – opens the webpage in the same tab.
  • _blank – opens the webpage on a new tab.
  • _parent – opens the web page in the parent frame.




4.Rel Attributes used in Anchor Tag

Relation attribute specifies the relation between the linked webpage and the current webpage.




<a href="URL" rel="value"></a>

The value is accepted in the rel attribute.

  1. nofollow
  2. alternate
  3. author
  4. bookmark
  5. noopener
  6. noreferrer
  7. license
  8. search
  9. external
  10. next
  11. prev
  12. help
  13. tag

Leave a comment below and let us know if you have any queries.

Restaurant Website Using HTML And CSS With Source Code

You can visit our other useful blog for collecting fronted development knowledge. thank you for visiting our website!

Written by: @OmBandiwan

Leave a Reply