1. Computing

Discuss in my forum

The A Tag

By

HTML5  tag

< Previous | HTML5 Tags HTML4 Tags | XHTML1 Elements | Next >

Free HTML Class | HTML Validators

A Description:

The a tag creates links (both anchors within the current page and to external pages) within an HTML document.

HTML5 also allows the creation of placeholder links by using the a tag without any attributes.

A Web Browser Support:

HTML Versions

A Attributes:

Global attributes and event attributes. Plus:

A End Tag:

</a> REQUIRED

A Contents:

CDATA Any text that you want linked. The following tags are valid within the <a> tag:
acronym, applet, b, basefont, bdo, big, br, button, cite, code, dfn, em, font, i, iframe, img, input, kbd, label, map, object, q, s, samp, script, select, small, span, strike, strong, sub, textarea, tt, u, var

A Valid Context:

The <a> tag is valid within the following tags:
acronym, address, applet, b, bdo, big, blockquote, body, caption, center, cite, code, dd, del, dfn, div, dt, em, fieldset, font, form, h1, h2, h3, h4, h5, h6, i, iframe, ins, kbd, label, legend, li, noframes, noscript, object, p, pre, q, s, samp, small, span, strike, strong, sub, sup, td, th, u, var

A Usage:

  • standard link with a title
    <a href="http://webdesign.about.com/" title="About.com Web Design and HTML">Web Design / HTML at About.com</a>
    View
  • named fragment
    <a name="bottom" id="bottom">the bottom of the page</a>
    link to this by typing:
    <a href="#bottom">link to the bottom of the page</a>
    View
  • link to a frame called "main"
    <a href="/od/frames" target="main">frame link</a>
    View
  • link in a series of pages
    <a href="/od/htmltags/p/bltags_abbr.htm" rel="Next" rev="Prev">Next</a>
    View
  • link with an access key
    <a href="/od/accessibility/" accesskey="a">access key is a</a>
    View

A Special Notes:

  • All of the attributes of the a tag are optional. The values for the element may then be set at a later time using dynamic scripts.
  • Keep the a tags as the innermost tag in a nest of tags. This isn't required, but it makes the code cleaner and easier to script.
  • If you set a target on a link and you're not in a frameset, that link will open in a new window with the name of that target.
  • Links with access keys will open when that access key is pressed in conjunction with the alt or command key on the keyboard. This makes pages more accessible.
  • Do not nest multiple a tags, this is not allowed.
  • When creating image links, make sure that the closing </a> tag is flush with the final > of the image tag. Otherwise, some browsers display the additional white space as a small underscore beside the image.

More A Information

< Previous | HTML5 Tags HTML4 Tags | XHTML1 Elements | Next >

 

©2014 About.com. All rights reserved.