Apollo Editor
Windows 10 & 11 Buy now · $69.95
Images & links

How to Add Links in HTML: Pages, Email, Phone Numbers, Anchors and Downloads

How to add every kind of link in HTML: other pages, external sites, email and phone links, jump links to a section, downloads and new-tab links.

Updated 5 minute read The Apollo Editor team

To add a link in HTML, wrap the clickable text in an <a> element and put the destination in its href attribute, like <a href="about.html">About us</a>. The same element handles links to other pages, external websites, email addresses, phone numbers, sections of the same page and file downloads. Only the value of href changes.

This guide walks through each type of link, explains relative and absolute paths, shows how to open links in a new tab safely, and covers how to write link text people can understand.

Every link has two parts: the address it goes to and the text (or image) people click.

  • <a href="contact.html">Contact us</a>

href stands for hypertext reference. The text between the opening and closing tags is the link text. Browsers style links as underlined blue text by default, and you can change that with CSS.

Pages on your site

For pages on your own site, use a relative path. It describes where the target file is compared with the current page, so the link keeps working whether the site is on your computer or on a web server.

Where the target isExample href
Same folder as the current pageabout.html
A subfolderservices/web-design.html
One folder up../index.html
From the root of the site (on a server)/contact.html

Paths that start with / are root-relative. They work on a web server but not when you open the files straight from your hard drive, so plain relative paths are often the safer choice for small static sites. Many servers are case sensitive, so About.html and about.html are treated as different files. Lowercase file names avoid that problem.

Other websites

For an external site, use the full absolute URL, including https://:

  • <a href="https://developer.mozilla.org/">MDN Web Docs</a>

If you leave out https://, the browser treats the address as a file on your own site, and the link breaks.

New-tab links

Add target="_blank" to open the link in a new tab. Add rel="noopener" as well so the new page cannot control the original one through JavaScript. Current browsers apply this protection automatically, but including it covers older browsers:

  • <a href="https://example.com/" target="_blank" rel="noopener">Example site</a>

Use new tabs sparingly. Many people prefer to decide for themselves, and an unexpected new tab can confuse screen reader users. It is most useful for links that would interrupt a task, such as a help page opened in the middle of a form.

A mailto: link opens the visitor's email app with your address filled in:

  • <a href="mailto:hello@example.com">hello@example.com</a>
  • <a href="mailto:hello@example.com?subject=Quote%20request">Request a quote</a>

Spaces in the subject are written as %20. Remember that a mailto link only works if the visitor has an email app set up, so it helps to show the address as the link text too.

A tel: link lets phone users tap to call. Use the full international number with no spaces in the href, and format the visible text however you like:

  • <a href="tel:+15551234567">(555) 123-4567</a>

To link to a specific section, give that section an id, then link to it with a # followed by the id:

  • <h2 id="pricing">Pricing</h2>
  • <a href="#pricing">See pricing</a>

You can also jump to a section on another page by combining the two: <a href="services.html#pricing">Pricing</a>. Each id must be unique on its page, should not contain spaces, and is case sensitive. Jump links are handy for tables of contents, FAQs and long single-page sites.

To link to a file such as a PDF, point href at the file. Adding the download attribute asks the browser to save it rather than open it:

  • <a href="files/menu.pdf" download>Download our menu (PDF, 300 KB)</a>

The download attribute only works for files on your own site. Telling visitors the file type and size in the link text helps them decide before they click.

To make an image clickable, put the <img> inside the link. The image's alt text becomes the link name, so describe where the link goes:

  • <a href="index.html"><img src="logo.svg" alt="Brightside Bakery home"></a>

Screen reader users often pull up a list of all links on a page, and everyone skims. Link text should make sense on its own.

  • Avoid "click here" and "read more". Write "Read our delivery policy" instead.
  • Keep it short. Link the key words, not a whole paragraph.
  • Be consistent. Links that go to the same place should use the same text.
  • Warn about surprises. Mention when a link opens a file, a new tab or an email app.

Typing paths by hand is where most link mistakes come from. Apollo Editor has a hyperlink editor that covers every link type in this guide from one place.

  • Select text or an image and choose Insert Link on the main toolbar to link to a page in your site, an external site, an email address, a phone number, an in-page anchor or a file download.
  • Set the link text and title, and turn on open in new tab, with the appropriate security attributes added for you.
  • Paths to your own pages are written as relative links, and internal links are updated automatically (after asking) when you rename or move a page in Site Explorer.
  • A site-wide broken link checker finds links that point nowhere before you publish.

You can still see and edit every <a> tag in Code or Split mode. Next, read how to find broken links, how to organize your website folders and the HTML basics for beginners guide.

Frequently asked questions

How do I make a link open in a new tab?

Add target="_blank". Adding rel="noopener" as well stops the new page from controlling the original one.

How do I link to a section on the same page?

Give the section an id, such as id="pricing", then link to it with href="#pricing".

How do I make a phone number clickable?

Use a tel: link with the full international number, such as href="tel:+15551234567".

Get three guides like this every month, plus software update notices.Subscribe →