link tag
frame tag
frameset tag
iframe tag
TAG: a
<a> ... </a>
Available in versions: 2.0, 3.2, 4.0
Browser compatibility: Explorer 4, 5 Netscape 4, 6
The
<a>
tag is called the anchor tag and it is most commonly used with the
href
attribute to create a hypertext link (usually referred to as just a link). By simply clicking on the link with a mouse or using a keyboard command, you can travel from one page to another page on the same web site or a different one. By default, the new page is normally displayed in the same window or frame, unless you specify otherwise using the
target
attribute.
Note that links cannot be nested. An
<a>...</a>
element cannot contain other
a
elements.
You can insert characters, images, line breaks (
<br>
or
<p>
), and text between the opening and closing
a
tags. It is recommended that you should not insert Cascading Style Sheets code or any other HTML tags between the opening and closing tags. Rather, place all such tags outside of the
a
element.
The closing tag is mandatory.
Core Attributes
class
dir
id
lang
onclick
ondblclick
onkeydown
onkeypress
onkeyup
onmousedown
onmousemove
onmouseout
onmouseover
onmouseup
style
title
Attributes
accesskey
The
accesskey
attribute allows you to designate a key on the keyboard that when pressed, along with the alt or meta key, activates a link. This attribute is poorly supported.
charset
The
charset
attribute is used to specify the character encoding used on the page that is the target of the link. Character encoding defines how a sequence of bytes is to be converted into characters for display.
coords
The
coords
attribute is currently not supported by most browsers. It is used to define an area of influence around the
a
tag.
href
The
href
attribute is used to specify the target URL address for a link.
hreflang
The
hreflang
attribute can only be used when the
href
attribute is also being used. It specifies the language of the page that is the target of the link.
name
The
name
attribute is a string of characters that is used to label an element with a name. The name must be unique to that document and cannot be reused. The name can be the target of a link.
onblur
The
onblur
attribute is an event that allows a JavaScript code to execute when an element loses focus (for example, the mouse was clicked onto another element or a tab navigation directed the cursor elsewhere).
onfocus
The
onfocus
attribute is an event that allows a JavaScript code to execute when an element comes into focus (for example, the mouse was clicked onto the element or a tab navigation brought the cursor to the element).
rel
The
rel
attribute is currently not fully supported by most browsers. It is a space-separated list of one or more values that specify the relationship from the source page to the target for a link. Some of the proposed values are,
appendix, bookmark, chapter, contents, copyright, glossery, help, index, next, prev, section, stylesheets,
and
subsection
.
rev
The
rev
attribute is currently not fully supported by most browsers. It is a space-separated list of one or more values that specify the relationship from the target page to the source for a link. Perhaps the most useful value is
relation
.
shape
The
shape
attribute is currently not supported by most browsers. It is used to define an area of influence around the
a
tag.
tabindex
The
tabindex
attribute specifies an integer that defines the rank in the tabbing order for the specified element when you use the keyboard to navigate (tab through) a page. This attribute is poorly supported.
target
The
target
attribute specifies the name of the frame or window in which the target page should appear when a link is clicked. The four reserved names are
_blank, _parent, _self,
and
_top
.
type
The
type
attribute specifies the content type of the target page of a link. It has a MIME encoding type value.
This example demonstrates the code for creating a link. The
target
attribute is used to open the linked document in a new window.
Code:
<a href="http://www.devguru.com" target="_blank">DevGuru</a>
Output:
DevGuru
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information