HTML Questions & Answers Logo
HTML Questions & Answers Part of the Q&A Network
Q&A Logo

How can I create an anchor link that jumps to a specific section on the same page?

Asked on Sep 28, 2025

Answer

To create an anchor link that jumps to a specific section on the same page, use the <a> tag with an href attribute pointing to the id of the target element. The target element should have a matching id attribute.
<!-- BEGIN COPY / PASTE -->
    <a href="#section1">Go to Section 1</a>

    <h2 id="section1">Section 1</h2>
    <p>This is the content of Section 1.</p>
    <!-- END COPY / PASTE -->
Additional Comment:
  • The href attribute in the <a> tag should start with a hash (#) followed by the target element's id.
  • The id attribute in the target element must be unique within the page.
  • Anchor links are useful for creating a table of contents or navigating long pages.

✅ Answered with HTML best practices.


← Back to All Questions
The Q&A Network