Content · Web Development · HTML

HTML URL Fragments and Scroll Targets with IDs

A fragment like #resources asks the browser to locate an element whose id is resources. A different file may be included before the fragment.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

A fragment like #resources asks the browser to locate an element whose id is resources. A different file may be included before the fragment. The important question is always where the link leads and whether the person reading the page can predict it.

What You Need to Know


The destination must exist when the page is opened. Keep fragments short, unique, and stable if other people might bookmark them.

Links are the pathways through a website. The words on a link should help someone choose where to go before clicking it.

Example: See It in Action


This example keeps the idea small. Copy it carefully, then follow the explanation instead of guessing what the browser will do.

This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.

<h2 id="resources">Resources</h2>
<p>Find downloads and project files here.</p>
<a href="#resources">Go to resources</a>
<a href="#top">Return to the top</a>

Let’s Understand the Example


  • An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
  • An h2 starts a major section beneath the page topic.
  • A p groups a paragraph of related text. Start another paragraph for a new thought.
  • Id gives one element a unique name within the page, so a link, label, or script can point to it.
  • Href contains the destination of a link. A value starting with # points to an id on the same page.

The first example link points to #resources. Check whether that destination exists relative to the document. A link changes where readers go; it does not perform an action such as saving a form.

What Should You See?


You should see a link named “Go to resources”. Selecting it leads to #resources when that destination exists. Try it with the mouse and the keyboard.

Imagine this link is read out of context. Would its text still explain the destination? Rename unclear links before trying to make them look nicer with CSS.

Try It Yourself


  1. Add a link from another HTML file to the resources section.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Adding a # to an arbitrary word without creating a matching id.
  • Avoid dead links, empty href values and clickable-looking text without a real destination.

Key Takeaways


  • A fragment like #resources asks the browser to locate an element whose id is resources.
  • An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
  • The destination must exist when the page is opened. Keep fragments short, unique, and stable if other people might bookmark them.
Share this resourceSend this page to someone who may find it useful.