TetSharing
HTML tutorial · 12 chapters
  1. Get started
  2. Elements and attributes
  3. Headings and paragraphs
  4. Text formatting
  5. Links
  6. Images
  7. Lists
  8. Tables
  9. Forms
  10. Input types and controls
  11. Semantic layout
  12. Head and metadata

Final HTML quiz

Chapter 5 of 12 · By Ethan Cole · Updated November 21, 2026

HTML Links: The a Element, href and target Explained

Links are what make the web a web. The <a> element (for "anchor") turns its content into a link, and its href attribute says where the link goes. Without href, an <a> is just a placeholder and is not clickable.

Kinds of URLs

  • Absolute URLs include the scheme and domain: https://www.sqlite.org/docs.html. Use them for other sites.
  • Root-relative URLs start with / and are resolved against the current site: /files/guide.pdf.
  • Relative URLs like about.html or ../index.html are resolved against the current page's folder.
  • Fragment links start with # and jump to the element with that id on the page, like href="#contact". Combine both, as in /python/lists/#common-mistakes, to jump to a section of another page.
HTML · editable

Expected page text

Links
Visit the SQLite documentation.
Python docs in a new tab
Jump to the contact section
Email us or call.
Download the guide
Contact
Back to top

Opening in a new tab

target="_blank" opens the link in a new tab or window. Use it sparingly; most people prefer to decide that themselves. Modern browsers treat _blank links as if rel="noopener" were set, which stops the new page from controlling the original one through window.opener. Adding rel="noopener" explicitly keeps older browsers safe too.

Special schemes and download

mailto: links open the visitor's email program, and tel: links start a call on phones. The download attribute asks the browser to save the linked file instead of navigating to it; it only works for files on the same site.

The text inside the link should make sense on its own, because screen-reader users often browse a list of all links on a page. "SQLite documentation" is useful; "click here" or "read more" is not. Search engines also use link text to understand the page being linked to.

Links can wrap almost any content, including images and whole blocks such as a card with a heading and summary. They cannot contain other links or interactive elements such as buttons.

Common mistakes

  • Forgetting the https:// in external links, which turns them into relative links on your own site.
  • Using <a> without href and a click handler as a fake button. Use <button> for actions and <a href> for navigation.
  • Link text like "here" that gives no hint of the destination.

Summary

  • <a href="..."> creates a link; the content is what users click.
  • URLs can be absolute, root-relative, relative or #fragment.
  • target="_blank" opens a new tab; pair it with rel="noopener".
  • Write link text that describes the destination.

Quiz: Links

1. Which link jumps to the element with id="faq" on the same page?

A fragment URL starts with # followed by the target id.

2. What does href="/about/" point to?

URLs starting with / are resolved from the site root.

3. Which is the best link text?

Descriptive text tells every user where the link leads.

Official docs

Written under the pen name Ethan Cole with AI-assisted drafting. Every code example on this page is executed by our test suite before publishing. Found a mistake? Tell us.