w3schools    w3Schools
Search W3Schools :
   
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About
ADVERTISEMENTS

XML Certification
Download XML editor
Custom Programming
 
Table of contents
HTML 5 Reference
HTML 5 by Alphabet
HTML 5 Attributes
HTML 5 Events

HTML5 Tags
<!-->
<!DOCTYPE>
<a>
<abbr>
<acronym>
<address>
<applet>
<area>
<article>
<aside>
<audio>
<b>
<base>
<basefont>
<bdo>
<big>
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center>
<cite>
<code>
<col>
<colgroup>
<command>
<datagrid>
<datalist>
<datatemplate>
<dd>
<del>
<details>
<dialog>
<dfn>
<dir>
<div>
<dl>
<dt>
<em>
<embed>
<event-source>
<fieldset>
<figure>
<font>
<footer>
<form>
<frame>
<frameset>
<head>
<header>
<h1> - <h6>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<label>
<legend>
<li>
<link>
<m>
<map>
<menu>
<meta>
<meter>
<nav>
<nest>
<noframes>
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rule>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike>
<strong>
<style>
<sub>
<sup>
<table>
<tbody>
<td>
<textarea>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<tt>
<u>
<ul>
<var>
<video>

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

W3Schools Tutorials
W3Schools Forum

Helping W3Schools

 

HTML 5 <a> tag


Definition and Usage

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


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 no longer supported.


Tips and Notes

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


Example

Source Output

<p>Linking to W3Schools:
<a href="http://www.w3schools.com">
W3Schools</a>
</p>

<p>
Opening W3Schools a new browser window:
<a href="http://www.w3schools.com"
target="_blank">W3Schools</a>
</p>

Linking to W3Schools: W3Schools

Opening W3Schools a new browser window: W3Schools



Attributes

  • 4: indicates if the attribute is defined in HTML 4.01
  • 5: indicates if the attribute is defined in HTML 5
Attribute Value Description 4 5
charset character_encoding Deprecated. Specifies the character encoding of the target URL 4  
coords

if shape="rect" then
coords="left,top,right,bottom"

if shape="circ" then
coords="centerx,centery,radius"

if shape="poly" then
coords="x1,y1,x2,y2,..,xn,yn"

Deprecated. Specifies the coordinates appropriate to the shape attribute to define a region of an image for image maps 4  
href URL The target URL of the link 4 5
hreflang language_code Specifies the base language of the target URL. Use only if the href attribute is present 4 5
media media query Specifies the mediatype of the target URL. Default value: all. Use only if the href attribute is present   5
name section_name Deprecated. Names an anchor. Use this attribute to create a bookmark in a document. Not supported. Use id instead. 4  
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

  5
rel alternate
archives
author
bookmark
contact
external
feed
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 4 5
rev alternate
designates
stylesheet
start
next
prev
contents
index
glossary
copyright
chapter
section
subsection
appendix
help
bookmark
Deprecated. Specifies the relationship between the target URL and the current document 4  
shape rect
rectangle
circ
circle
poly
polygon
Deprecated. Defines the type of region to be defined for mapping in the current area tag. Used with the coords attribute. 4  
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
4 5
type mime_type Specifies the MIME (Multipurpose Internet Mail Extensions) type of the target URL. Use only if the href attribute is present 4 5

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.


Try-It-Yourself Demos

Create hyperlinks
How to create hyperlinks.

An image as a link
How to use an image as a link.

Open a link in a new browser window
How to open a link in a new browser window, so that the visitor does not have to leave your Web site.

Create a mailto link
How to link to a mail message (will only work if you have mail installed).

Create a mailto link 2
Another mailto link.



DreamTemplate



diploma   

Get Your Diploma!

W3Schools' Online Certification Program is the perfect solution for busy professionals who need to balance work, family, and career building.

The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.

The JavaScript Certificate is for developers who want to document their knowledge of JavaScript and the HTML DOM.

The XML Certificate is for developers who want to document their knowledge of XML, XML DOM and XSLT.

The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.

The PHP Certificate is for developers who want to document their knowledge of PHP and SQL (MySQL).


 
WEB HOSTING
Web charting
Web based charting
for ASP.NET
$15 Domain Name
Registration
Save $20 / year!
Buy UK Domain Names
Register Domain Names
Cheap Domain Names
Cheap Web Hosting
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
FREE Web Hosting
WEB BUILDING
Website Templates
Flash Templates
Website Builder
Internet Business Opportunity
Custom Programming
FREE Trial or Demo
Web Content Manager
Forms,Web Alerts,RSS
Download XML editor
FREE Flash Website
FREE Web Templates
EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification
Home HOME or Top of Page Validate   Validate   W3C-WAI level A conformance icon Printer Friendly  Printer Friendly

W3Schools is for training only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user.
While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright 1999-2009 by Refsnes Data. All Rights Reserved.