ADVERTISEMENT

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

Telegram Group Join Now

ADVERTISEMENT

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

anchor tag html | How to use Anchor tag

 

ADVERTISEMENT

ADVERTISEMENT

 

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

ADVERTISEMENT

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.

ADVERTISEMENT

50+ HTML, CSS & JavaScript Projects With Source Code

Given below is an example of an anchor tag :

ADVERTISEMENT

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.

Syntax:

ADVERTISEMENT

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

e.g.:

ADVERTISEMENT

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

Syntax:

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

ADVERTISEMENT

E.g. :

ADVERTISEMENT

ADVERTISEMENT

3.Hreflang Attributes used in Anchor Tag

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

ADVERTISEMENT

Syntax:

ADVERTISEMENT

<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.
Syntax:
<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.

E.g:

4.Rel Attributes used in Anchor Tag

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

Syntax:

<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

ADVERTISEMENT

Telegram Group Join Now

Share on:

Leave a Comment

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT