HTML 5 <a> Tag
Example
A link to W3Schools.com:
| <a href="http://www.w3schools.com">Visit W3Schools.com!</a> |
Try it yourself »
|
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 HTML 5
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.
Tips and Notes
Tip: The attributes: hreflang, media, ping, rel, target, and type attributes can not 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
| Attribute |
Value |
Description |
| href |
URL |
The target URL of the link |
| hreflang |
language_code |
Specifies the base language of the target URL. Use only if
the href attribute is present |
| media |
media query |
Specifies the mediatype of the target URL. Default value:
all. Use only if the href attribute is present |
| 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 |
| 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 |
| 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
|
| type |
mime_type |
Specifies the MIME (Multipurpose Internet Mail Extensions) type of the target URL.
Use only if the href attribute is present |
Standard Attributes
| class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark, tabindex, template, title |
For a full description, go to Standard Attributes in HTML 5.
Event Attributes
| onabort, onbeforeunload, onblur, onchange, onclick,
oncontextmenu, ondblclick, ondrag, ondragend, ondragenter, ondragleave,
ondragover, ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress,
onkeyup, onload, onmessage, onmousedown, onmousemove,
onmouseover, onmouseout, onmouseup, onmousewheel, onresize, onscroll, onselect,
onsubmit, onunload |
For a full description, go to Event Attributes
in HTML 5.

Whether you're new to XML or already an advanced user, the user-friendly views and powerful entry helpers, wizards, and debuggers in XMLSpy are designed to meet your XML and Web development needs from start to finish.
New features in Version 2010!
- XML editor
- Graphical XML Schema / DTD editors
- XSLT 1.0/2.0 editor, debugger, profiler
- XQuery editor, debugger, profiler
- XBRL validator, taxonomy editor, taxonomy wizard
- Support for Office Open XML (OOXML)
- Graphical WSDL 1.1/2.0 editor & SOAP debugger
- JSON editing & conversion
- Java, C#, C++ code generation
- 32-bit and 64-bit versions
- And much more!
Download a free trial today!
|
|
|
 |
W3Schools' Online Certification Program
The perfect solution for professionals who need to balance work, family, and career building.
More than 4500 certificates already issued!
|
The HTML Certificate documents your knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
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).
|