HTML <a> (Anchor) Tag
Example
<a href="https://www.w3seekers.com">Visit W3Seekers.com!</a>
Meaning
This element defines a hyperlink, the named target destination for a hyperlink, or both.
Version: HTML 2, 3.2, 4, 4.01, 5
Standard Syntax
<a href="URL" >...</a>
Browser Support
Status
Tips and Notes:
- Note: If you use the accesskey attribute with this element page, be wary of reserved bindings.
- Tip: Use for target elements inside the web page
Attributes
Attribute | Value | Description |
---|---|---|
download | fileName | Download the link instead of navigating it. |
href | URL | Hyperlink of the page used to navigate |
hreflang | languageCode | Language of the hyperlinked page or document. |
media | mediaQuery | Specification suggests the value should be used to indicate whether a destination is appropriate for screen, print, PDA, and so on |
ping | URL(S) | This Specific attribute is used to specify the URL(s) that will be notified when a link is activated. |
referrepolicy | no-referrer no-referrer-when-downgrade origin origin-when-cross-origin same-origin strict-origin-when-cross-origin unsafe-url |
This specifies which referrer information to send with the hyperlink. |
rel | alternate author bookmark external help license next nofollow noreferrer noopener prev search tag |
This attribute specifies the relationship of the target object to the link object. |
target | _blank _parent _self _top |
This attribute specifies the target window for a hypertext source link that references frames. |
type | mediaType | This attribute specifies the media type in the form of a MIME type for the link target. |
Deprecated Attributes
Attribute | Value | Description |
---|---|---|
charset | characterSet | This attribute defines the character encoding of the linked resource. |
coords | coordinates | this attribute uses a comma-separated list of numbers to define the coordinates of the object on the page. |
name | id or name | This attribute is required in an anchor defining a target location within a page. |
rev | alternate author bookmark external help license next nofollow noreferrer noopener prev search tag |
This attribute specifies a reverse link, the inverse relationship of the rel attribute. |
shape | circle, default, polygon, and rect | This attribute is used to define a selectable region for hypertext source links associated with a figure in order to create an image map. |
Global Attributes
<a> element also supports the Global Attributes in HTML.
Event Attributes
<a> element also supports the Event Attributes in HTML.
More Examples
How to use an image as a hyperlink
Example
<a href="https://www.google.com">
<img alt="Google" src="smiley.png" width="50" height="50">
</a>
How to open a hyperlink in a new browser window.
Example
<a href="https://www.google.com" target="_blank">Visit google.com!</a>
How to hyperlink to an email address
Example
<a href="mailto:[email protected]">Send email</a>
How to hyperlink to on the same page
Example
<a href="#chapter2">Go to Chapter 2</a>
How to hyperlink to a JavaScript
Example
<a href="javascript:alert('Hello World!');">Click me to Execute.</a>
By Default CSS Value/s
Most of the browsers will display the <a> element with the following by default value(s)
a:link, a:visited {
color: (internal value);
text-decoration: underline;
cursor: auto;
}
a:link:active, a:visited:active {
color: (internal value);
}