asp.net.ph

Skip Navigation Links

A Element | A Object

Language References


Defines the destination of a hypertext link.HTML 2, 3.2, 4, 4.01, 5

HTML Syntax

Remarks

The A element is commonly used to:

  • link to another hypertext document, or
  • link to a specific location within the same, or another, hypertext document

The A element requires either the:

  • href attribute when used as a hypertext link, to specify the link’s destination URI.
  • id attribute when used as an anchor, to identify the anchor’s location within a document.

Both text and images can be included within an <a> element used as a hyperlink.

The <a> element is not restricted to HTTP-based URLs. It can also use the following URL schemes supported by most browsers.

  • Telephone numbers with tel: URLs
  • Email addresses with mailto: URLs
  • SMS text messages with sms: URLs
  • Executable code with javascript: URLs

Browsers typically render textual hyperlinks with a different color and an underline, though authors may use CSS styles to override this default behavior.

NOTE: Both start and end tags are required.

Attributes

The <a> element supports the following attributes, in addition to global attributes common to all HTML elements.

AttributeValueDescription
downloadfilenameCauses the browser to treat the linked URL as a download.
hrefURLSpecifies the URL that the hyperlink points to.
hreflanglanguage_codeSpecifies the language of the linked document.
mediamedia_querySpecifies what media/device the linked document is optimized for
pingurl_listSpecifies a space-separated list of URLs, typically used for tracking.
referrerpolicyno-referrer, no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin-when-cross-origin, unsafe-urlSpecifies which referrer information to send with the link.
relalternate, author, bookmark, external, help, license, next, nofollow, noreferrer, noopener, prev, search, tagSpecifies the relationship between the current document and the linked document.
target_blank, _parent, _self, _topSpecifies where to open the linked document.
typemedia_typeSpecifies the media type of the linked document

Example

Following are several examples of using the <a> element.

Linking to an absolute path:

<a href="https://asp.net.ph">Home</a>
Result: Home

Specifying a named location that can be used as the destination of other links:

<h3><a id="atts">Attributes</a></h3>

Linking to a location within the same document:

<a href="#atts">Attributes</a>
Result: Attributes

Specifying the target window or frame to load the linked resource:

<a href="somewhere.com" target="travel">Destinations</a>
Result: Destinations

Using an image as a hyperlink:

<a href="somewhere.com"><img src="home.png"></a>


Calling a JavaScript function compliant with the ECMA-262 language specification ( ex. opens a new window ):

<a href="javascript:window.open ( )">Show me</a>
Result: Show me
See Also

LINK   Anchors and Links



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note