Tag <a> HTML Reference



Example

A link to google.com:

<a href="http://www.google.com">Visit Google.com!</a>

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

1. Definition and Usage

The <a> tag defines an anchor. An anchor can be used in two ways:

  1. To create a link to another document, by using the href attribute
  2. To create a bookmark inside a document, by using the name attribute

The <a> element is usually referred to as a link or a hyperlink.

The most important attribute of the <a> element is the href attribute, which indicates the link's destination.

By default, links will appear as follows in all browsers:

  • An unvisited link is underlined and blue
  • A visited link is underlined and purple
  • An active link is underlined and red

2. Tips and Notes

Tip: The following attributes: download, hreflang, media, rel, target, and type cannot be present if the href attribute is not present.

Tip: A linked page is normally displayed in the current browser window, unless you specify another target.

Tip: Use CSS to style links.


3. Differences Between HTML 4.01 and HTML5

In HTML 4.01, the <a> tag could be either a hyperlink or an anchor. In HTML5, the <a> tag is always a hyperlink, but if it has no href attribute, it is only a placeholder for a hyperlink.

HTML5 has some new attributes, and some HTML 4.01 attributes are no longer supported.


4. Optional Attributes

DTD indicates in which HTML 4.01/XHTML 1.0 DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.

Attribute Value Description DTD
charset char_encoding Specifies the character-set of a linked document STF
coords coordinates Specifies the coordinates of a link STF
href URL Specifies the URL of the page the link goes to STF
hreflang language_code Specifies the language of the linked document STF
name section_name Specifies the name of an anchor STF
rel text Specifies the relationship between the current document and the linked document STF
rev text Specifies the relationship between the linked document and the current document STF
shape default
rect
circle
poly
Specifies the shape of a link STF
target _blank
_parent
_self
_top
framename
Specifies where to open the linked document TF


5. Standard Attributes

The <a> tag also supports the Standard Attributes in HTML.


6. Event Attributes

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


Relative articles