HTML5 Tutorials & More

<a> Tag

The <a> tag defines an anchor.

Supported In HTML4: Yes

Supported In HTML5: Yes

HTML4 vs HTML5 Differences: In HTML 4.01, the <a> tag could be either a hyperlink or an anchor. This was determined by the href attribute. In HTML 5, the <a> tag is always a hyperlink, but if it has no href attribute, it is only a placeholder for a hyperlink. HTML 5 has some new attributes, and some HTML 4.01 attributes are not supported in HTML 5.

Attributes

Title Values Description HTML4 Support HTML5 Support
charset char_encoding Yes No
coords coordinates No No
href URL The target URL of the link. No No
hreflang language_code Specifies the base language of the target URL. Use only if the href attribute is present. No No
media media query Specifies what media/device the target URL is optimized for. Use only if the href attribute is present. Default value: all. No No
name section_name No No
ping URL Space separated list of URL's that gets notified when a user follows the hyperlink. Use only if the href attribute is present. No No
rel alternate, archives, author, bookmark, contact, external, first, help, icon, index, last, license, next, nofollow, noreferrer, pingback, prefetch, prev, search, stylesheet, sidebar, tag, up Specifies the relationship between the current document and the target URL. Use only if the href attribute is present. No No
rev text No No
shape default, rect, circle, poly No No
target _blank, _parent, _self, _top Where to open the target URL. Use only if the href attribute is present. _blank - the target URL will open in a new window. _self - the target URL will open in the same document as it was clicked. _parent - the target URL will open in the parent document. _top - the target URL will open in the full body of the window. No No
type mime_type Specifies the MIME (Multipurpose Internet Mail Extensions) type of the target URL. Use only if the href attribute is present. No No

Standard Attributes

All standard attributes are supported.

Event Attributes

All event attributes are supported.

HTML5 Tags