Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Text Content  ›  Lesson

Links: The a Element

Links 12 minThe a element with an href makes a link to another page, a place on the same page, an email address or a phone number, and its text should say where it leads.

Links: The a Element

Links are what make the web a web. The "HT" in HTML, HyperText, means exactly this: text that leads somewhere else. One element does all of it, and one attribute decides where it goes.

The rule

a plus href goes somewhere; the link text says where.

A link is an a (anchor) element with an href (hypertext reference):

<a href="https://www.example.org/timetable">Train timetable</a>

The value of href decides the destination:

href value Goes to
https://site.example/page an absolute URL: a full address, often another site
about.html or /team/ a relative URL: a page on your own site
#faq a place on the same page with id="faq"
mailto:hello@site.example a new email to that address
tel:+911234567890 a phone call, on devices that can make one

Jumping within a page works by pairing a fragment with an id:

<a href="#faq">Jump to questions</a>
...
<h2 id="faq">Frequently asked questions</h2>

target="_blank" opens the link in a new tab. Use it sparingly and say so in the link text, because unexpected tabs disorient people, especially screen reader users. Modern browsers already protect the original page from the new tab, so you no longer need extra attributes for that in most cases.

The link text matters. Screen readers can list every link on a page, stripped of the sentence around it. "Click here", "read more" and "link" become meaningless in that list. Write text that makes sense on its own: "Download the 2026 fee schedule (PDF)".

The shortcut

Build every link in two questions: where does it go, and what will the person get? The first answer is href; the second is the link text.

Linking to a returns policyStep 1 of 4
  1. Where does it go?

    A page on the same site, so a relative path from the site root: href="/help/returns".

The trap is an a without href, or a link whose text only works in context. Both leave keyboard and screen reader users stuck.

Drills

Answer fast — trust the rule.

quick drill

Which attribute sets where a link goes?

quick drill

Which href jumps to <section id="prices"> on the same page?

quick drill

Which link text is the most accessible?

quick drill

What does <a href="mailto:help@shop.example">Email support</a> do?

quick drill

A link opens a partner site in a new tab. What should you add?

Remember

  • a + href makes a link: absolute, relative, #id, mailto: or tel:.
  • Shortcut: href answers "where?", link text answers "what will I get?"
  • Trap: "click here" text, missing href, and unannounced new tabs.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainFixing vague links

A page has three links that all say 'click here': one to the fee schedule PDF, one to an external partner's site that opens in a new tab, and one to the contact section lower on the same page. Rewrite them and explain your choices.