You are here: Reference > HTML > tags > a

a element

Browser support:
Defines a link to the same or to another document, or defines a destination anchor.
The a (anchor) tag is one of the most useful HTML elements.
You can define a destination anchor with the name or a source anchor with the href attribute of the a element. A source anchor can refer to a document, a file or a destination anchor, or it can open the email client of the user, or it can execute a JavaScript code.
The following table contains protocols that can be used in the value of the href attribute.
Commonly used protocols:
  • Inner links:
    The inner links are useful to create a destination point where the browser may jump directly (scrolling the target to the top of the page if possible). The target must be an anchor tag with the name attribute specified, and if you want to jump to this point, you must only insert the value of the name attribute after a # (hash mark) sign in the href attribute of the source anchor or area element, as shown in Example 2.
  • http, https:
    Link to an external webpage, as shown in Example 1.
  • ftp:
    Opens a file transfer session (an FTP site), with or without a username and password, as shown in Example 4.
  • file:
    Allows downloading a file from the specified location. Because of security restrictions, most browsers allow downloading files only from the same domain where the original document is placed.
  • javascript:
    Allows the execution of JavaScript code, as shown in Example 5.
  • mailto:
    Opens the 'new message' dialog of user's default e-mail application with the specified e-mail address as the recipient, as shown in Example 3.
If you want to see the HTML tags by categories, please visit this page.
This element requires a closing tag.
JavaScript page for this element: a.

Possible members:

Sets an access key to an element.
Sets the character encoding of the document, a linked document or a script block.
Sets the style class or classes that belong to the element.
Sets whether the contents of the object are editable.
Sets the position of a shape. You can select the type of shape with the shape attribute.
Specifies which field of a given data source should be bound to the specified object.
Sets the identifier of the data source that is bound to the element.
Sets the text direction as related to the lang attribute.
Sets the state of an object for user interaction.
Sets whether an element is draggable.
Specifies whether a dotted rectangle (focus rectangle) is drawn around an object while it has focus.
Specifies the location of the destination.
Sets the language of a linked resource or anchor element.
Sets a unique identifier for the object.
Specifies the language of the element.
Sets the scripting language for the current element. Use it only for the script element.
Specifies a comma-separated list of HTTP METHODS supported by the object and accessible to the user.
Sets the name of a target anchor.
Specifies the relationship between the current document and the destination of an anchor or link.
Specifies a reverse relationship from an anchor or link to the current document.
Sets the shape type of the selectable region for a hypertext or an area.
Sets whether the automatic spellchecker is enabled.
Sets an inline style associated with an element.
Specifies the tabbing order for keyboard navigation using the TAB key.
Specifies the target window or frame where the document is to be opened.
Specifies a tooltip for an element.
Specifies the content type (MIME type) of the object or the linked object.
Sets whether the selection process can start in an element's content.
Specifies a Uniform Resource Name (URN) for a linked object.
Sets the language code of the XML document.

Example HTML code 1:

This example shows how to create an external link:
<a href="" target="_blank">External Link</a>
Did you find this example helpful? yes no

Example HTML code 2:

This example shows how to jump to a destination anchor on the current page:
<a href="#to">External Link</a>

<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />

<h1 id="to">The goal of the jump</h1>
Did you find this example helpful? yes no

Example HTML code 3:

This example shows how to send mail with the anchor tag:
<a href="">Send mail</a>
Did you find this example helpful? yes no

Example HTML code 4:

This example shows how to create a link to a protected ftp:
<a href="">FTP with password</a>
Did you find this example helpful? yes no

Example HTML code 5:

This example shows how to execute JavaScript code from a href attribute:
<a href="javascript: alert ('You clicked the link.')">Execute JavaScript</a>
Did you find this example helpful? yes no

Related pages:

External links:

User Contributed Comments

Post Content

Post Content