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.

AttributeValueDescriptionDTD
charsetchar_encodingSpecifies the character-set of a linked documentSTF
coordscoordinatesSpecifies the coordinates of a linkSTF
hrefURLSpecifies the URL of the page the link goes toSTF
hreflanglanguage_codeSpecifies the language of the linked documentSTF
namesection_nameSpecifies the name of an anchorSTF
reltextSpecifies the relationship between the current document and the linked documentSTF
revtextSpecifies the relationship between the linked document and the current documentSTF
shapedefault
rect
circle
poly
Specifies the shape of a linkSTF
target_blank
_parent
_self
_top
framename
Specifies where to open the linked documentTF


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