Link to a specific section of your web page – HTML

Preview

To view this and the other 250+ tutorials on Simple Dev, sign up for a 10-day free trial.

Summary

<a href="#last-section">Link text</a>

<!-- Other HTML code might be here -->

<h2 id="last-section">Header</h2>

Details

To create a link to a specific section of your web page, use an anchor element with the href attribute and use the ID of another element on the page as the value (prefixed with a hash sign):

<a href="#last-section">Link text</a>

<!-- Other HTML code might be here -->

<h2 id="last-section">Header</h2>

Demo

Link to specific section demo

Exercises

Recreate the embedded CodePen demo by adding an anchor element to the HTML code. Then add an id attribute to the last heading (look for the comments for hints).

References

The Anchor element on MDN

Lesson tags: Open Lesson
Back to: HTML Course > HTML Links