A &bittersweet& Lesson On Copyright
A definition is - the 1st letter of the English alphabet. How to use a in a sentence.
Watch full episodes of current and classic USA shows online. Plus find clips, previews, photos and exclusive online features on USANetwork.com. Free delivery on millions of items with Prime. Low prices across earth's biggest selection of books, music, DVDs, electronics, computers, software, apparel & accessories, shoes, jewelry, tools & hardware, housewares, furniture, sporting goods, beauty & personal care, groceries & just about anything else.
Example
Create a link to W3Schools.com:
More 'Try it Yourself' examples below.
Definition and Usage
The <a>
tag defines a hyperlink, which is used to link from one page to another.
The most important attribute of the <a>
element is the href
attribute, which indicates the link's destination.
By default, links will appear as follows in all browsers:
- An unvisited link is underlined and blue
- A visited link is underlined and purple
- An active link is underlined and red
Tips and Notes
Tip: If the <a>
tag has no href
attribute, it is only a placeholder for a hyperlink.
Tip: A linked page is normally displayed in the current browser window, unless you specify another target.
Tip: Use CSS to style links: CSS Links and CSS Buttons.
Browser Support
Element | |||||
---|---|---|---|---|---|
<a> | Yes | Yes | Yes | Yes | Yes |
Attributes
Attribute | Value | Description |
---|---|---|
download | filename | Specifies that the target will be downloaded when a user clicks on the hyperlink |
href | URL | Specifies the URL of the page the link goes to |
hreflang | language_code | Specifies the language of the linked document |
media | media_query | Specifies what media/device the linked document is optimized for |
ping | list_of_URLs | Specifies a space-separated list of URLs to which, when the link is followed, post requests with the body ping will be sent by the browser (in the background). Typically used for tracking. |
referrerpolicy | no-referrer no-referrer-when-downgrade origin origin-when-cross-origin same-origin strict-origin-when-cross-origin unsafe-url | Specifies which referrer information to send with the link |
rel | alternate author bookmark external help license next nofollow noreferrer noopener prev search tag | Specifies the relationship between the current document and the linked document |
target | _blank _parent _self _top | Specifies where to open the linked document |
type | media_type | Specifies the media type of the linked document |
Global Attributes
The <a>
tag also supports the Global Attributes in HTML.
Event Attributes
The <a>
tag also supports the Event Attributes in HTML.
More Examples
Example
How to use an image as a link:
<img border='0' alt='W3Schools' src='logo_w3s.gif' width='100' height='100'>
</a>
Example
How to open a link in a new browser window:
Example
How to link to an email address:
Example
How to link to a phone number:
Try it Yourself »Example
How to link to another section on the same page:
Try it Yourself »Example
How to link to a JavaScript:
Related Pages
HTML tutorial: HTML Links
HTML DOM reference: Anchor Object
CSS Tutorial: Styling Links
Default CSS Settings
Most browsers will display the <a>
element with the following default values:
A Million Little Things
color: (internal value);
text-decoration: underline;
cursor: auto;
}
a:link:active, a:visited:active {
color: (internal value);
}
The HTML <a>
tag is used for creating an a
element (also known as an 'anchor' element).
The a
element represents a hyperlink. This is usually a link to another document.
You can use the <a>
tag to link text or images. You can also link a large block of content (even containing multiple elements) if required - it's not just restricted to hyperlinking single elements. However, there must be no 'interactive content' descendant.
Syntax
The <a>
tag is written as <a href='></a>
with the linked URL between the double quotes of the href
attribute and the anchor text (i.e. the text that the user sees) between the start and end tags.
Like this:
A &bittersweet& Lesson On Copyright Act
Examples
Basic tag usage
Open the link in a new window (or tab)
Here we use target='_blank'
to open the link in a new window.
Reload the new window
Here we open multiple links in a new window, but instead of a new window being opened with each link, a new window is opened with the first link, then the following links load their contents into that window.
We do this simply by giving the target
attribute a name that doesn't exist (i.e. we make up our own name for the window/tab).
Linked Image
Here we wrap the <a>
around an image to create a linked image.
No-Follow
Here we use rel='nofollow'
to create a 'nofollow' link. This can be used to tell search engines that you don't endorse the content at the other end of the link. The nofollow
attribute value is typically used on paid links and advertising.
Many people refer to this as the 'nofollow tag' but it's not actually a tag. It's not even an attribute (the attribute is rel
). The nofollow
bit is simply a value of the rel
attribute.
Attributes
Attributes can be added to an HTML element to provide more information about how the element should appear or behave.
The <a>
element accepts the following attributes.
Attribute | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
href | Specifies the URL of a page that the link goes to. | ||||||||||||||||||||||||||||||
target | Specifies the default browsing context to load the URL into. Only to be used when the href attribute is present. Possible values:
| ||||||||||||||||||||||||||||||
download | Indicates that the link is to be used for downloading a resource (such as a file). The author can specify a default file name by providing a value. This attribute is optional. Value: [Default file name.] (optional) | ||||||||||||||||||||||||||||||
rel | Describes the relationship between the current document and the destination URI. Only to be used when the href attribute is present. Multiple values can be provided, separated by a space. Possible values:
| ||||||||||||||||||||||||||||||
rev | Reverse link relationship of the destination resource to this document (or subsection/topic). | ||||||||||||||||||||||||||||||
hreflang | Language code of the destination URL. Only to be used when the href attribute is present. | ||||||||||||||||||||||||||||||
type | Specifies the MIME type of the linked resource. Only to be used when the href attribute is present. | ||||||||||||||||||||||||||||||
referrerpolicy | Referrer policy for fetches initiated by the element. |
Global Attributes
The following attributes are standard across all HTML elements. Therefore, you can use these attributes with the <a>
tag , as well as with all other HTML tags.
accesskey
autocapitalize
class
contenteditable
data-*
dir
draggable
hidden
id
inputmode
is
itemid
itemprop
itemref
itemscope
itemtype
lang
part
slot
spellcheck
style
tabindex
title
translate
For a full explanation of these attributes, see HTML 5 global attributes.
Event Handlers
Event handler content attributes enable you to invoke a script from within your HTML. The script is invoked when a certain 'event' occurs. Each event handler content attribute deals with a different event.
onabort
onauxclick
onblur
oncancel
oncanplay
oncanplaythrough
onchange
onclick
onclose
oncontextmenu
oncopy
oncuechange
oncut
ondblclick
ondrag
ondragend
ondragenter
ondragexit
ondragleave
ondragover
ondragstart
ondrop
ondurationchange
onemptied
onended
onerror
onfocus
onformdata
oninput
oninvalid
onkeydown
onkeypress
onkeyup
onlanguagechange
onload
onloadeddata
onloadedmetadata
onloadstart
onmousedown
onmouseenter
onmouseleave
onmousemove
onmouseout
onmouseover
onmouseup
onpaste
onpause
onplay
onplaying
onprogress
onratechange
onreset
onresize
onscroll
onsecuritypolicyviolation
onseeked
onseeking
onselect
onslotchange
onstalled
onsubmit
onsuspend
ontimeupdate
ontoggle
onvolumechange
onwaiting
onwheel
Most event handler content attributes can be used on all HTML elements, but some event handlers have specific rules around when they can be used and which elements they are applicable to.
For more detail, see HTML event handler content attributes.