href attribute | href property
Sets or retrieves a destination URL or an anchor point.
the URL or anchor point.
- Document Object Model (DOM) Level 1 Specification, Section 2.5.5
- HTML 4.01 Specification, Section 12.2
When specified for an a element (also called an anchor element), HREF defines a link to another document or another location within the document containing the a element. By default, the text between the opening and closing tags of the anchor element is underlined and the location specified by the HREF attribute is loaded when the user activates the link.
The value of the HREF can be a URL that loads a separate document when the link is activated, or a fragment identifier. Fragment identifiers, orbookmarks, define target locations within a document that are brought into view when links are activated. Use the NAME attribute of a separate anchor element to define a bookmark as a target location within a document.
The img element does not support the HREF content attribute. In addition, the href property is read-only for the img Document Object Model (DOM) object.
If HREF is specified as a blank value (
href=), executing the link might display the directory containing the current document, or it might generate an error, depending on other elements in the document and the server environment.
This example function returns the href property of the current page location.