a element | a object
[This documentation is preliminary and is subject to change.]
Designates the start or destination of a hypertext link.
![]() ![]() |
Standards information
- Document Object Model (DOM) Level 2 HTML Specification, Section 1.6.5
- HTML 4.01 Specification, Section 1
HTML information
| Closing Tag | required |
|---|---|
| CSS Display | inline |
Remarks
The a element requires the href or the name attribute to be specified.
Both text and images can be included within an anchor. An image that is an anchor has a border whose color indicates whether the link has been visited. To prevent this border from appearing, you can set the img element's border attribute to 0 or omit the border attribute. You can also use Cascading Style Sheets (CSS) attributes to override the default appearance of a and img elements.
Note A table object does not function properly when contained within an a tag.
Windows Internet Explorer 8 and later. The value of the href attribute depends on the current document compatibility mode.
Internet Explorer 8 and later. When Protected Mode is enabled and a Web page contains an anchor link with a named target, Windows Internet Explorer opens the target of the link in a new window when the target has a different integrity level than the Web page containing the link. For more information, see Understanding and Working in Protected Mode Internet Explorer.
Examples
The following examples use the a element to link to files, open a file, include an image as part of a link, define an anchor, and invoke a function.
<!-- Link to a server. --> <A HREF="http://www.microsoft.com">Microsoft home page.</A> <!-- Link to a file in the same directory. --> <A HREF="home.htm">home.htm</A> <!-- Open a file in the window specified by TARGET. --> <A TARGET="viewer" HREF="sample.htm">Open in window</A> <!-- Include an IMG element as a part of the link. --> <A HREF="http://www.microsoft.com"><IMG SRC="images/bullet.png">link</A> <!-- Link to an anchor. --> <A HREF="#anchor">anchor</A> <!-- Define an anchor. --> <A NAME="anchor"> <!-- Invoke a JScript function. --> <A HREF="javascript:window.open()">link</A>
Build date: 3/8/2012
IE8 appears to ignore the 'self-closed' aspect of an <a> tag, and instead scans forward to find the next </a>. While the bookmark part still works, if (for instance) you have a <p> tag on the way, IE8 will 'self-close' that <p> tag prematurely.
So always use an explicit </a> tag with each bookmark <a name='target'> tag.
- 6/2/2010
- J Kurtock

