Document fragments

Link to specific parts of an HTML document

tag

Use id attribute to mark elements you want to link to

link

Reference the id with a hash symbol (#) in the URL

location_on

Browser scrolls to the element with matching id

// Target element with id attribute
<h2 id="mailing-address">Mailing address</h2>

// Link to the element
<a href="#mailing-address">Go to mailing address</a>
lightbulb Common Use Cases

Table of contents, "Back to top" links, FAQ sections, and navigation within long documents

Example of a webpage with document fragment links
format_list_bulleted Table of Contents Example