HyperText Markup Language/Tag List/a

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Use[edit | edit source]

The anchor element (a) is used to define anchors, or hyperlinks. You can use it to refer to other pages with the href attribute (Hyperlink Reference).

Example[edit | edit source]

<a href="http://en.wikibooks.org/" accesskey="w" hreflang="en" title="Click here for very good books">Wikibooks</a>

DTD[edit | edit source]

Strict, Transitional and Frameset, for both HTML 4 and XHTML 1.0.

a is an inline element.

Optional attributes[edit | edit source]

charset[edit | edit source]

This attribute allows you to specify the character encoding of the target location

coords[edit | edit source]

href[edit | edit source]

With the href attribute you specify the destination of the hyperlink, in other words, the page a visitor will be sent to when he clicks the link.

hreflang[edit | edit source]

This attribute allows you to specify the language of the target page.

name[edit | edit source]

This allows you to specify a name for the hyperlink, for use as a bookmark. Note that in XHTML, you should use the id attribute.

rel[edit | edit source]

Allows you to specify the relation of the current to the target page. In other words, what the target page is, Possible values are alternate, appendix, bookmark, chapter, contents, copyright, designates, glossary, help, index, next, prev, section, start, stylesheet and subsection.

rev[edit | edit source]

Allows you to specify the relation of the target page to the current page. In other words, what the current page is. This should be the same for all hyperlinks in the current page. For possible values, see rel above.

shape[edit | edit source]

target[edit | edit source]

This attribute can only be used in transitional and frameset XHTML documents. It is used to tell the browser where to open the targeted URL. The user has Four options to choose from:

  • _blank: The URL will open in a new window.
  • _parent: Will open in the parent frameset.
  • _self: Will open in the same window/tag as it was clicked on.
  • _top: Will open in the full body window.

type[edit | edit source]

This lets you specify the Multipurpose Internet Mail Extensions type of the targeted URL.

Standard attributes[edit | edit source]

Notes[edit | edit source]

In Microsoft Internet Explorer, this is the only element on which the CSS pseudo-class selector hover works.

More info[edit | edit source]

The <a> tag on W3Schools