W3Schools.com

HTML5 <a> Tag

Example

A link to W3Schools.com:

<a href="http://www.w3schools.com">Visit W3Schools.com!</a>

Try it yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The <a> tag is supported in all major browsers.


Definition and Usage

The <a> tag defines a hyperlink, which is used to link from one page to another.

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

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 not supported in HTML5.


Tips and Notes

Tip: The attributes: hreflang, media, rel, target, and type attributes 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.


Attributes

New : New in HTML5.

Attribute Value Description
charset char_encoding Not supported in HTML5
coords coordinates Not supported in HTML5
href URL Specifies the URL of the page the link goes to
hreflang language_code Specifies the language of the linked document
media New media_query Specifies what media/device the linked document is optimized for
name section_name Not supported in HTML5
rel alternate
author
bookmark
help
license
next
nofollow
noreferrer
prefetch
prev
search
tag
Specifies the relationship between the current document and the linked document
rev text Not supported in HTML5
shape default
rect
circle
poly
Not supported in HTML5
target _blank
_parent
_self
_top
framename
Specifies where to open the linked document
type New MIME_type Specifies the MIME type of the linked document

Global Attributes

The <a> tag also supports the Global Attributes in HTML5.


Event Attributes

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



W3Schools Certification

W3Schools' Online Certification

The perfect solution for professionals who need to balance work, family, and career building.

More than 10 000 certificates already issued!

Get Your Certificate »

The HTML Certificate documents your knowledge of HTML.

The CSS Certificate documents your knowledge of advanced CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The jQuery Certificate documents your knowledge of jQuery.

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The ASP Certificate documents your knowledge of ASP, SQL, and ADO.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE