Skip to main content
Module 1 · Lesson 3 of 43/60 in the course~16 min
Module lessons (3/4)

Links, Navigation & URL Paths

Links Are the Glue of the Web

The H in HTML stands for HyperText—text wired together by clickable <a href="..."> anchors. Unlike <button> elements (which trigger in-page actions like submitting a form or opening a modal), an <a> element navigates somewhere with a URL.

Link PatternUse CaseExample
Relative pathSubpage inside current folder<a href="pricing.html">Pricing</a>
Root-relative pathRoute anchored from domain root /<a href="/docs/intro">Docs</a>
Absolute URLExternal domain<a href="https://developer.mozilla.org">MDN</a>
Fragment anchorJump directly to an element id on the page<a href="#faq">Jump to FAQ</a>
Safe external new tabOpens safely without window.opener access<a href="https://example.com" target="_blank" rel="noopener noreferrer">

Example 1 — Navigation List & Same-Page Anchor

Wrapping navigation links inside <nav> with an unordered list gives screen reader users a clean landmark and a count of links ("navigation, list, 3 items"):

HTML
<nav aria-label="Primary">
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/courses">Courses</a></li>
    <li><a href="#contact">Jump to Contact</a></li>
  </ul>
</nav>

<section id="contact">
  <h2>Contact</h2>
  <p>Write to <a href="mailto:hello@example.test">hello@example.test</a>.</p>
</section>

Example 2 — Never Write "Click Here"

Screen reader users often pull up a flat list of every link on the page out of context. Calling every link "Click here" or "Read more" turns that list into guesswork.

HTML
<!-- Vague: useless when listed alone -->
<p>To check holiday shipping dates, <a href="/shipping">click here</a>.</p>

<!-- Descriptive: clear in any context -->
<p>Check our <a href="/shipping">2026 holiday shipping schedule</a>.</p>
Practice Stage

Step 1 — Wire a descriptive external link safely

Exercise#html-css.m1.l3.e1
Attempts: 0Loading…

Update the anchor so it links to 'https://web.dev' safely with target='_blank' and rel='noopener noreferrer', and replace 'Click here' with descriptive text mentioning 'Web.dev performance guides'.

Loading editor…
Show hint

Add rel="noopener noreferrer" to the <a> tag and change the link label from "Click here" to "Read the Web.dev performance guides".

Solution available after 3 attempts

Practice Stage

Step 2 — Connect a page Table of Contents with fragment anchors

Exercise#html-css.m1.l3.e2
Attempts: 0Loading…

Wire the two navigation links using href='#overview' and href='#pricing', and add matching id attributes on the two <section> tags.

Loading editor…
Show hint

Change href="#" to href="#overview" and href="#pricing", and set id="overview" / id="pricing" on the matching sections.

Solution available after 3 attempts

Practice Stage

Step 3 — Build a skip link + header navigation bar

Exercise#html-css.m1.l3.e3
Attempts: 0Loading…

Add an anchor href='#main-content' labeled 'Skip to main content' before <nav>, add links to '/docs' and '/blog' inside <nav>, and give <main> id='main-content'.

Loading editor…
Show hint

Add <a href="#main-content">Skip to main content</a> above <nav>, wrap Documentation and Engineering Blog in <a> links with "/docs" and "/blog", and add id="main-content" to <main>.

Solution available after 3 attempts

HTML & CSS Quiz#html-css.m1.l3.e4
Ready

You are inside '/courses/html/intro.html'. Where does a link with href='/about' navigate versus href='about'?

Answer options
HTML & CSS Quiz#html-css.m1.l3.e5
Ready

What happens for keyboard users if you omit the href attribute from an <a> tag?

HTML
<a class="nav-btn">Open Dashboard</a>
Answer options