How to create a link

Understand what a link does and how to make one.

A link, or hyperlink, is an interactive component on a web page. When a user clicks or presses it, it sends the browser to another location or resource.

Examples of what a link does

Activating a link might:

  • take the user to a section elsewhere on the same page
  • take the user to a new page — on the same or a different website
  • open the user’s default email application with a new draft email ready to be written
  • open a file, like a PDF, in an appropriate application, such as Adobe Reader.

A link’s target location or resource is identified with a URL (Uniform Resource Locator).

These are some examples of URLs:

If the interactive component that you want to create does not send the user to another location or resource — in other words, if there is no URL involved — then you probably want to use a different one, like a button.

Note: A link should not:

  • be used for creating a button
  • be designed to look like a button.

Designing a link to look like a link and a button to look like a button is important. This is because each has a distinct role and how the component looks will tell the user something about:

There are a few ways to create a link.

Using the <a> or <area> element with the href attribute

A link created using an <a> or <area> element with an href attribute is keyboard accessible by default. This means that it can be focused using the Tab key and activated by pressing the Enter key.

An <a> or an <area> element without an href attribute is not a link.

<a> element

Using the <a> element with an href attribute is the most common way to make a link in HTML — the ‘a’ stands for ‘anchor’.

The href (hypertext reference) attribute identifies the anchor’s target and takes a valid URL as its value.

With an <a href> element, the link’s text or content normally sits within the <a> element’s opening and closing tags, but it can come from other sources. See How links get accessible names.

For more information and examples of how to use the <a> element, see:

<area> element

The <area> element with an href attribute creates a link in an image map, that is, an image with geometric regions that are hyperlinked.

The href (hypertext reference) attribute identifies the <area> element’s target and takes a valid URL as its value.

An <area> element, just like an <img> element, requires an alt attribute that provides a text equivalent for people who cannot see or understand what the linked region of the image map represents.

For more information and examples of how to use the <area> element and image maps, see:

In almost all cases, it’s recommended to use native HTML link elements.

Sometimes, however, a developer will repurpose some other HTML element to serve as a link. Such custom links need extra work to make them accessible. For more on what some of that work involves, see: