href Attribute


 

Where to use the href Attribute

  • As Type URI - #REQUIRED:
    href is declared on the element: base
  • As Type URI:
    href is declared on the elements: link, a, area

Description

The href attribute specifies a URI.

On the base element

On the base element, the href attribute gives the base URI for the document (i.e. the URI from which all relative URIs in the document should be resolved). This must be an absolute URI. See also the codebase attribute of the object element.

On other elements

On the a, link and area elements, the href attribute gives the target location of the link, which may be either an absolute or relative URI.

Note: If an empty string is assigned to the href attribute of one of these hyperlink elements, this is usually interpreted as a link to the beginning of the document at the current URI (or base URI, if different): i.e. a link to the current (or base) URI, including any query string but stripping off any fragment identifiers. However, some user agents do not interpret a blank href in this manner - e.g. Konqueror, which seems to remove also any 'filename' from the current (or base) URI (i.e. anything following the final slash - but retaining any query string). For maximum cross-browser compatibility (which, in my opinion, is a must for any public resource), this means that links to the top of the current page should be made explicitly to an anchor located there, e.g. href="#top", rather than by using href="".


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 16 May 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Indexes > Attribute Index (XHTML 1.1) > href Attribute (XHTML 1.1)