Document Fragments to link to a specific part of an HTML document

HTML - Hypertext Markup Language

Created: 2022-08-21
Tags: #fleeting


Document Fragment,

  1. Assign an id attribute to the element you want to link to.
  2. Use <a> and href with the following value
    • "filename.html#id_name"

Example of document fragment linking to a specific heading

<h2 id="Mailing_address">Mailing address</h2>
<p>Use our <a href="contacts.html#Mailing_address">mailing address</a> to send feedback.</p>