Learn Anchor tag in HTML with its attributes

Anchor tag <a> in html

To navigate from page to page or to navigate within the page. HTML provides us an anchor tag.

< a> is use to create Anchor Tag

— Anchor tag allows us to create hyperlink in HTML document.

— Anchor tag allows us to create link button which will help us to navigate from one page to another or to navigate within the page

— Anchor tag has following attributes

    — href (click here)

    —target (click here)

    — name (click here)

    — download (click here)

    — hreflang (click here)

    — type(click here)

There are two types of links

— External Linking

    > When we create a link to navigate from one document to another document it is known as external linking.

    > href=”https://itvoyagers.in”

— Internal Linking

    > When we create a link to navigate with in the page then it is known as internal linking.

    > href=”#footerpart”


href attribute

Hypertext reference most important attribute in anchor tag.

In this attribute we have to enter location of the targeted file which we wish to open once the link is click. 

If both initial and targeted documents are in same folder then there is no need to specify complete location of target file in href or else we have to enter complete path of the document.

If we want to create inner link then we have to add “#” as a prefix to value.

Syntax : href = “path_of_target_document”


External Linking :


Internal Linking :


href attribute in anchor tag
Output :

External Linking-
ITVoyagers Website

Internal Linking-

Target attribute

Target attribute is use to specify where to open link document.

Target attribute specify has following values.

_blank” — It will open targeted document in new tab or new window.


_self” — It will open targeted document in same frame (it is default).


_parent” — It will open targeted document in parent frame


_top” — It will open document in full body of window 


framename” — It will open targeted document in named frame

Syntax : target=”value”

e.g. name=”_blank

Best post on Frame Widget of tkinter in Python

name attribute

Name attribute is use to label the section in page.

It is use to create internal link.

We have to specify name attribute’s value in href with “#” prefix to create internal link.


Syntax : name=”name_of_section”

e.g. name=”footerpart

name attribute in anchor tag

download attribute

If we want to allow downloading of file once the link is click the we have to add “download” attribute in anchor tag and we have to specify the path of the file in “href” attribute.

Syntax : download=”boolean_value”

e.g. download=”true

download attribute in anchor tag

hreflang attribute

Type attribute is use to specify the type of targeted document

Syntax : hreflang=”language_code”

e.g. hreflang=”en”

hreflang attribute in anchor tag

type attribute

Type attribute is use to specify the type of targeted document

Syntax : type=”media_type”

e.g. type=”text/html”

type attribute in anchor tag

Also checkout our other related post.

Leave a Comment