link tag
frame tag
frameset tag
TAG: a
<a> ... </a>
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 separate closing tag is mandatory.
Attributes and Events
accesskey
class
dir
id
lang
onblur
onclick
ondblclick
onfocus
onkeydown
onkeypress
onkeyup
onmousedown
onmousemove
onmouseout
onmouseover
onmouseup
tabindex
title
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.
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.
target
- not allowed in Strict XHTML
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:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="eng">
<head>
<title>DevGuru XHTML a Tag Example</title>
</head>
<body>
<
a href="http://www.devguru.com" target="_blank
"> DevGuru<
/a
>
</body>
</html>
Output:
DevGuru
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information