HTML Tag Reference - HTML tag <a>

This element defines a hyperlink, the named target destination for a hyperlink, or both.

href attribute has the URL linking to other web page or resource. label is used to display information for web page visitors.

<a href="">label</a>

Anchor name starts with #. It marks a linkable area inside a page. We can use anchor link to hyperlink to a specific part in a web page.

<a href="#anchorName">label</a>

Standard Syntax

    charset="character code for language of linked resource"
    class="class name(s)"
    coords="comma-separated list of numbers" 
    dir="ltr | rtl"
    href="URL" hreflang="language code"
    id="unique alphanumeric identifier" 
    lang="language code"
    name="name of target location"
    rel="comma-separated list of relationship values" 
    rev="comma-separated list of relationship values" 
    shape="default | circle | poly | rect" 
    style="style information"
    target="frame or window name | _blank | _parent | _self | _top" 
    title="advisory text"
    type="content type of linked data"


Browser compatibility

<a> Yes Yes Yes Yes Yes

What's new in HTML5

HTML5 has some new attributes, and some HTML 4.01 attributes are deprecated.


char encoding of a linked document. Not supported in HTML5.
the coordinates of a link. Not supported in HTML5.
the target will be downloaded when clicking the hyperlink. New in HTML5
the URL of the link
the language code of the linked document
media/device the linked document is optimized for. New in HTML5.
Specifies the name of an anchor. Not supported in HTML5. Use the global id attribute instead.
Possible values:alternate|author|bookmark|help|license|next|nofollow|noreferrer| prefetch|prev|search|tag. Relationship between the current document and the linked document
Not supported in HTML5.
Possible values:default|rect|circle|poly. Not supported in HTML5. The shape of a link
Possible values:_blank|_parent|_self|_top|framename. Where to open the linked document.
New in HTML5. Media type of the linked document.

Global Attributes

The <a> tag supports the Global Attributes in HTML.

Event Attributes

The <a> tag supports the Event Attributes in HTML.

Default CSS Settings

a:link, a:visited { 
    color: (internal value);
    text-decoration: underline;
    cursor: auto;

a:link:active, a:visited:active { 
    color: (internal value);


A demo showing how to use anchor tag to create hyperlink and anchor.

     <a name="top"></a>
     <a href=""></a>
     <a href="#par3">Go to paragraph #3 in this page</a>
     <p><a href="yourdocument.html#sty">
        Go to the yourdocument.htm page,sty location</a></p>
     <p><a name="par3">Paragraph #3</a></p>
     <p><a href="#top">Top</a></p>
</body><!-- w w  w  .  j  ava 2s.  c o  m-->

Click to view the demo