LESSON 21 OF 120

Build: an in-page section link

Connect navigation to an existing section with a unique fragment.

Official sourceWHATWG HTML — linksReviewed: 2026-08-26
STEP 1 · LEARN

How it works

Connect navigation to an existing section with a unique fragment. Semantic structure should describe meaning, not visual appearance.

Correct example
<nav><a href="#contact">Contact</a></nav><section id="contact"><h2>Contact</h2></section>

An href beginning with # points to a fragment in the current page. The text after # must match the target element’s unique id.

Common mistake
<nav><a href="#contact">Contact</a></nav><section><h2>Contact</h2></section>

The link points to #contact, but no element has id="contact". The navigation has no valid target.

STEP 2 · APPLY

Your exercise

Complete the example. Connect navigation to an existing section with a unique fragment.

STEP 3 · BUILD

Write and see the result

index.htmlHTML
Safe resultisolated
The draft stays only in this browser.HTML and CSS allowed · scripts and network blocked
STEP 4 · CHECK

What needs to pass

0%not checked
  • The link points to #contact.
  • The target with id="contact" exists.
Explain the solution logic

Add the link with href="#contact" and assign exactly id="contact" to the destination section.