Menu

Linking to Sections on the Same Page

Linking to Sections on the Same Page

Sometimes you want a link that jumps to a specific part of the same page, instead of loading a new one. This is common in long articles with a table of contents at the top.

To do this, you give an element an id, and then point a link to that id using a hash symbol.

<a href="#pricing">Jump to Pricing</a>

 

<!-- further down the page -->

<h2 id="pricing">Pricing</h2>

<p>Here are our plans...</p>

Explanation:

  • The id value must be unique on the page, meaning no two elements should share the same id.
  • The href in the link matches the id exactly, with a hash symbol placed right before it.

HTML Tutorial (From Basics to Implementation)

AP

Abhishek Pati





Get in Touch For Details