HTML a tag (2024)


Example

Create a link to W3Schools.com:

<a href="https://www.w3schools.com">Visit W3Schools.com!</a>

Try it Yourself »

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:

<a href="https://www.w3schools.com">
<img border="0" alt="W3Schools" src="logo_w3s.gif" width="100" height="100">
</a>

Try it Yourself »

Example

How to open a link in a new browser window:

<a href="https://www.w3schools.com" target="_blank">Visit W3Schools.com!</a>

Try it Yourself »

Example

How to link to an email address:

<a href="mailto:someone@example.com">Send email</a>

Try it Yourself »

Example

How to link to a phone number:

<a href="tel:+4733378901">+47 333 78 901</a>

Try it Yourself »

Example

How to link to another section on the same page:

<a href="#section2">Go to Section 2</a>

Try it Yourself »

Example

How to link to a JavaScript:

<a href="javascript:alert('Hello World!');">Execute JavaScript</a>

Try it Yourself »

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:link, a:visited {
color: (internal value);
text-decoration: underline;
cursor: auto;
}

a:link:active, a:visited:active {
color: (internal value);
}

W3schools Pathfinder

Track your progress - it's free!

HTML a tag (2024)

FAQs

What does the HTML tag A? ›

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.

What does the A in the HTML a tag stand for? ›

In HTML, the "a" tag is used to create a hyperlink, which allows you to navigate to another web page or a different section of the same page. The "a" stands for "anchor" because it creates a link that acts as an anchor point for navigation.

What is a href tag in HTML? ›

The href attribute specifies the URL of the page the link goes to. If the href attribute is not present, the <a> tag will not be a hyperlink. Tip: You can use href="#top" or href="#" to link to the top of the current page!

What are the 7 HTML tags? ›

Basic HTML Tags
  • <h1></h1> This tag defines the HTML headings. ...
  • <p></p> This tag defines a paragraph. ...
  • <img> The image tag allows us to insert images into a web page. ...
  • <a></a> The <a> tag or the anchor tag allows us to link one web page to another page or a section of the same page. ...
  • <! – Comment –>
Oct 29, 2023

How to code a link in HTML? ›

How to Code a Link in HTML
  1. <a> </a> Next, add your homepage's URL using the href attribute:
  2. <a href="https://www.yourhomepage.com"> </a> Now, add the anchor text people will click to go to your link:
  3. <a href="https://www.homepage.com>Visit our homepage</a> Your anchor text should be descriptive.
Sep 19, 2023

What are the 20 tags in HTML? ›

Basic HTML
TagDescription
<h1> to <h6>Defines HTML headings
<p>Defines a paragraph
<br>Inserts a single line break
<hr>Defines a thematic change in the content
6 more rows

Which ______ attribute is used with the A tag? ›

The HREF attribute in the Anchor Tag <A> is used to specify the URL or web address of the page or resource that the hyperlink is linking to. When a user clicks on the hyperlink, they will be redirected to the specified URL.

What is the purpose of a tag? ›

Overview. People use tags to aid classification, mark ownership, note boundaries, and indicate online identity. Tags may take the form of words, images, or other identifying marks. An analogous example of tags in the physical world is museum object tagging.

How to anchor a link in HTML? ›

Navigate to where you want to insert an anchor. In the HTML code, insert the anchor using the format id=“anchor_name” within the <p> tag. Note: IDs on a page must be unique, and can't be re-used for other anchors.

How do I make a link clickable? ›

Create a hyperlink to a location on the web

Select the text or picture that you want to display as a hyperlink. Link. You can also right-click the text or picture and click Link on the shortcut menu. In the Insert Hyperlink box, type or paste your link in the Address box.

How do I link two HTML pages? ›

HTML Linking Basics
  1. Attributes for the <a> tag: href - This is the most used attribute for the <a> tag. This is what is used to create a hyperlink. ...
  2. Example: <a href="somewhere. html" name="linktome" id="linktome" target="_blank">Go Somewhere</a> This tag will create both a link and an anchor.

Is href required for a tag? ›

Answer. Links that are built with anchor elements ( <a> ) are not accessible without an href value.

What are the 3 required HTML tags? ›

HTML contains four essential tags that form the basic structure of any webpage or HTML file:
  • <html></html>
  • <head></head>
  • <title></title>
  • <body></body>
Aug 20, 2021

What are the 3 main HTML tags? ›

HTML tags contain three main parts: opening tag, content and closing tag.

What are the 4 basic HTML structural tags? ›

These tags are <html> , <head> , <title> and <body> . The <html> tags must begin and end the document and the <head> tags must appear before the <body> tags. Also, the <title> tags must be within the <head> tags.

What are the HTML symbols? ›

HTML symbols are characters generally not found on a keyboard. They include mathematical operators, greek letters, currencies, and more. HTML entity notation ( &...; ) is used for these HTML symbols. If no entity name is available for a symbol, then use the entity number or hex notation.

What does the HTML tag indicate? ›

HTML Tags: HTML tags are used to define the structure and content of an HTML document. They enclose content and determine the type of element represented. For example, <p> tags indicate a paragraph element, <div> tags define a division or container, and <a> tags create hyperlinks.

What does b mean in HTML? ›

Definition and Usage

The <b> tag specifies bold text without any extra importance.

What are the tags used for in HTML? ›

Content (Container) Tags
Opening TagClosing TagDescription
<span></span>A container for in-line content, such as content inside a paragraph.
<em></em>Gives the contained text emphasis (usually as italics).
<strong></strong>Makes the contained text bold.
<a href = "document location"></a>Link
7 more rows

Top Articles
Latest Posts
Article information

Author: Pres. Lawanda Wiegand

Last Updated:

Views: 6449

Rating: 4 / 5 (71 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Pres. Lawanda Wiegand

Birthday: 1993-01-10

Address: Suite 391 6963 Ullrich Shore, Bellefort, WI 01350-7893

Phone: +6806610432415

Job: Dynamic Manufacturing Assistant

Hobby: amateur radio, Taekwondo, Wood carving, Parkour, Skateboarding, Running, Rafting

Introduction: My name is Pres. Lawanda Wiegand, I am a inquisitive, helpful, glamorous, cheerful, open, clever, innocent person who loves writing and wants to share my knowledge and understanding with you.