Você está na página 1de 3

HTML <a> Tag

Example
A link to W3Schools.com:

<a href="http://www.w3schools.com">Visit W3Schools.com!</a>


Try it yourself

(more examples at the bottom of this page)

Definition and Usage


The <a> tag defines an anchor. An anchor can be used in two ways: 1. 2. To create a link to another document, by using the href attribute To create a bookmark inside a document, by using the name attribute

The a element is usually referred to as a link or a hyperlink. The most important attribute of the a element is the href attribute, which indicates the links destination. By default, links will appear as follows in all browsers:

y y y

An unvisited link is underlined and blue A visited link is underlined and purple An active link is underlined and red

Browser Support

The <a> tag is supported in all major browsers.

Differences Between HTML and XHTML


NONE

Tips and Notes


Tip: Use CSS to style links!

Optional Attributes

DTD indicates in which HTML 4.01/XHTML 1.0 DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset. Attribute charset coords href hreflang name rel rev shape Value char_encoding coordinates URL language_code section_name text text default rect circle poly _blank _parent _self _top framename Description Specifies the character-set of a linked document Specifies the coordinates of a link Specifies the destination of a link Specifies the language of a linked document Specifies the name of an anchor Specifies the relationship between the current document and the linked document Specifies the relationship between the linked document and the current document Specifies the shape of a link DTD STF STF STF STF STF STF STF STF

target

Specifies where to open the linked document

TF

Standard Attributes
The <a> tag supports the following standard attributes: Attribute accesskey class dir id lang style tabindex title xml:lang Value character classname rtl ltr id language_code style_definition number text language_code Description Specifies a keyboard shortcut to access an element Specifies a classname for an element Specifies the text direction for the content in an element Specifies a unique id for an element Specifies a language code for the content in an element Specifies an inline style for an element Specifies the tab order of an element Specifies extra information about an element Specifies a language code for the content in an element, in XHTML documents DTD STF STF STF STF STF STF STF STF STF

More information about Standard Attributes.

Event Attributes
The <a> tag supports the following event attributes: Attribute Value Description DTD

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

script script script script script script script script script script script script

Script to be run when an element loses focus Script to be run on a mouse click Script to be run on a mouse double-click Script to be run when an element gets focus Script to be run when mouse button is pressed Script to be run when mouse pointer moves Script to be run when mouse pointer moves out of an element Script to be run when mouse pointer moves over an element Script to be run when mouse button is released Script to be run when a key is pressed Script to be run when a key is pressed and released Script to be run when a key is released

STF STF STF STF STF STF STF STF STF STF STF STF

More information about Event Attributes.

Você também pode gostar