HTML Fragment Links: Jump to Page Sections
Jump to an element ID
A URL fragment begins with #. When a same-document fragment matches an element ID, the browser can scroll to that element. Use a unique ID per document, match its spelling and case, and avoid spaces in IDs.
<a href="#schedule">Jump to schedule</a><h2 id="schedule">Schedule</h2><p>Monday: orientation.</p>Activating the link updates the fragment to #schedule and targets the heading. A short page may not visibly scroll.
Link to another page section
A fragment can follow another page URL. The browser first resolves and loads that document when needed, then seeks its target. The destination page must contain the matching ID.
<a href="guide.html#tools">Tools in the guide</a>This targets the element with id="tools" in guide.html. The destination is a separate file, not included in the snippet.
Avoid broken or ambiguous destinations
A misspelled ID does not identify the intended section. Duplicate IDs make targeting ambiguous and are invalid authoring. An empty fragment (#) can navigate to the top; do not use it as a placeholder for an unrelated action.
<a href="#faq">Read the FAQ</a><h2 id="faq">Frequently asked questions</h2><p>Bring your own notebook.</p><a href="#">Back to top</a>The first link targets the FAQ heading; the second targets the top of this document.
Practice and next steps
Add a second destination called resources to the first example and link to it. Change its ID and observe the broken link.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Fragment Links: Jump to Page Sections — Knowledge Check
Check the core concepts from this lesson.
Which href targets id="details" in the same document?
Where must id="tools" exist for guide.html#tools?
What should you do if two sections have id="faq"?
What does a fragment identifier normally identify in a document?
A link points to #prices but the heading has id="price". What is the fix?