Back to the html tags list

HTML <a> Tag - Anchor

The <a> tag is used to make a click able link to another page, bookmark on a page or email address.

Where/how To Use The <a> Tag

Use in head or body section? body
Inline or Block level tag? Inline
HTML Tag Syntax? <start tag>CONTENT</end tag>
XHTML Tag Syntax? <start tag>CONTENT</end tag>

Example

   Code

   Preview


Notes

  • 'A' tag is commonly referred to as an anchor.

  • Use the "target" attribute to open pages accordingly (In a new page etc).

  • Also use the "target" attribute to link frames/iframes. (by id or name attribute on frame)

  • There are no differences between XHTML and HTML for this tag

Attributes for the a (anchor) tag

Attribute

Description

Value(s)

DOCTYPE

Strict DOCTYPE Attributes

href

Destination URL

URL

Strict, Transitional and Frameset

charset

Character Label

Label

Strict, Transitional and Frameset

coords

The coords attribute is used on an image map to specify the area which is clickable on an image

If shape= circle or circ
Coords would be: centerX, centerY, radius

If shape= rectangle or rect
Coords would be: Left Top CornerX, Left Top CornerY, Right Bottom CornerX, Right Bottom CornerY

If shape= polygon or poly
Coords would be: X1, Y1, X2, Y2, X3, Y3
every set of coordinates is one point of the polygon. Three sets would be a triangle and so on.
(one set is: X1, Y1)

Strict, Transitional and Frameset

hreflang

Defines the overall language code for the target URL

language code

Strict, Transitional and Frameset

name

Used to make a bookmark on a document.
The id attribute is used for XHTML documents.

user-defined-name

Strict, Transitional and Frameset

rel

Describes how the target URL relates to the current document.

alternate
appendix
bookmark
chapter
contents
copyright
designates
glossary
help
index
next
prev
section
start
stylesheet
subsection

Strict, Transitional and Frameset

rev

Describes the reverse relationship between the target URL and the current document.

alternate
appendix
bookmark
chapter
contents
copyright
designates
glossary
help
index
next
prev
section
start
stylesheet
subsection

Strict, Transitional and Frameset

shape

This attribute is used on an image map. It defines the clickable shape. Use this attribute with the coords attribute.

circ
circle
poly
polygon
rect
rectangle

Strict, Transitional and Frameset

type

Defines the MIME type of the target URL

MIME type

Strict, Transitional and Frameset

Non-Strict DOCTYPE Attributes

target

Where or how to open the link

•_blank - Opens the link in a new window
•_parent - Opens the link in the parent frame
•_self - Opens the link in the same frame as it was clicked
•_top - Breaks all frames, and then opens the target URL

_blank
_parent
_self
_top

Transitional and Frameset

Common attributes for the a(anchor) tag

class, style, id, title, dir, xml:lang, lang, accesskey, tabindex

Details for Common html Attributes.

Javascript Event attributes for the a(anchor) tag

onmousedown, onmouseup, onclick, ondblclick, onmouseover, onmouseout, onmousemove, onkeydown, onkeyup, onkeypress, onfocus, onblur

Details for Javascript Event Attributes.


Back to the html tags list