Content · Web Development · HTML

HTML HTML ID References: Connecting Elements with IDs

An id gives one element a document-wide identifier. Links can use #id to jump to that element, and other attributes can point to it to create relationships.

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

An id gives one element a document-wide identifier. Links can use #id to jump to that element, and other attributes can point to it to create relationships.

What You Need to Know


The id must be unique on the page. A broken or repeated ID can send keyboard users and assistive technologies to the wrong place.

An ID used by a fragment or label must match the target exactly, and it should be unique within the document.

The goal is not to collect as many tags as possible. Pick the element that best describes what the content really is.

Example: See It in Action


Take a look at this small piece of HTML. You can use it in a practice document and change the text to make it your own.

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="schedule">Today's schedule</h2>
<a href="#schedule">Jump to the schedule</a>
<p aria-labelledby="schedule">The heading names this section.</p>

Let’s Understand the Example


  • An h2 starts a major section beneath the page topic.
  • An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
  • 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.
  • Aria-labelledby uses one or more existing element ids to name another element.

The first example link points to #schedule. 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?


The page should display “Today's schedule” as a heading, followed by its related content. Change the heading text and refresh the browser to see the result.

Read only the headings, from top to bottom. Do they tell a sensible story? If not, move sections or choose levels that match the content.

Try It Yourself


  1. Add a second section with a different id and create a link to it.
  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


  • Copying the same id onto several headings because they look similar.
  • Avoid picking tags just for their default bold, italic or spaced appearance. Use CSS for presentation.

Key Takeaways


  • An id gives one element a document-wide identifier.
  • An h2 starts a major section beneath the page topic.
  • An ID used by a fragment or label must match the target exactly, and it should be unique within the document.
Share this resourceSend this page to someone who may find it useful.