How to Link to a Specific Section of a Document

Learn how to link to a specific section of a document with web page anchors or PDF page links, plus testing tips and a fallback for readers.

Published
Reading time
5 min read
How to Link to a Specific Section of a Document
On this page

A link to a specific section of a document can save readers from scrolling through pages of material. The method depends on the document: web pages commonly use heading anchors, while PDFs may use viewer-specific page links. Here’s how to create each kind—and what to tell readers if the link doesn’t land in the right place.

Key Takeaways

  • A URL fragment—the part after #—can point to an element on a web page, such as a heading with an id.
  • For a PDF, a link such as #page=12 may open a particular page, but behavior varies by browser, viewer, and hosting setup.
  • Test the link while signed out or in a private window to check that the document is actually public.
  • Include a page number or section name as a fallback in case the deep link does not work.

A URL fragment is the part of a URL after the #. On a web page, the browser can use that fragment to find an element with a matching id and move the page to it. The fragment is not part of the page path or query string.

For example, a page might have this heading:

<h2 id="sharing-the-document">Sharing the document</h2>

A link to that heading is:

https://example.org/guide#sharing-the-document

The fragment must match the element’s id. IDs should be unique on the page; if several elements use the same ID, the destination may be unpredictable.

If you control the page, choose a short, descriptive ID and keep it stable. Changing an ID can break links that people have already shared. If you are linking to someone else’s page, use the heading’s existing link or copy the fragment from the address bar after selecting the heading, if the site provides that option. Automatic heading anchors differ between publishing platforms, so don’t assume a heading’s text always converts to the same URL fragment.

Advertisement

Some PDF viewers recognize a page number in the URL fragment. For example:

https://example.org/handbook.pdf#page=12

This asks a compatible viewer to open page 12 of the PDF. Put the fragment after the PDF URL; if the URL already has a query string, the fragment still comes last:

https://example.org/handbook.pdf?download=0#page=12

Viewer support and behavior can vary with the browser, PDF viewer, and how the file is hosted. A link may open the PDF at its first page, download the file, or display it in a viewer that ignores the page fragment. Also check whether the page number you mean is the PDF’s actual page index or a number printed on the page: front matter can make those differ.

I could not test these examples in multiple browsers for this article. Treat the PDF example as a common format, not a guarantee that every browser or hosting setup will honor it. Test the exact shared URL in the environment your readers are likely to use.

  1. Open the document in the same way your audience will access it.
  2. For a web page, find the heading’s anchor link or use its matching id in the URL fragment.
  3. For a PDF, try the desired page fragment, such as #page=12, in the URL the host provides.
  4. Copy the complete URL, including everything after #.
  5. Open it in a private window or while signed out. Confirm both that the document is accessible and that the destination is useful.
  6. If possible, check it in another browser or viewer, especially when sharing a PDF with a broad audience.

A URL parser can help you inspect a link’s components, but it cannot confirm that a viewer will honor a PDF fragment or that recipients have permission to open the document.

Advertisement

Give readers a fallback

Add a short note next to the link, such as: “If the link opens at the beginning, go to page 12” or “If needed, scroll to the ‘Sharing the document’ heading.” This helps when a viewer ignores the fragment, a platform changes its heading anchors, or the reader opens the file in a different application.

For a document that must be easy to navigate, make the destination clear in the link text and provide another way to find it—such as a section title, page number, or table-of-contents entry. Avoid link text like “click here” on its own; a descriptive label makes the destination easier to understand.

Common Mistakes

  • Leaving off the fragment: A link ending at guide opens the document, but not necessarily the intended section. Include #section-id or the PDF viewer fragment.
  • Guessing an anchor: Heading-anchor formats vary by platform. Copy the actual anchor when available, or verify the destination after creating the link.
  • Using the printed PDF page number without checking: The PDF viewer’s page index may not match the number printed on the page.
  • Assuming a link grants access: A deep link does not change document permissions. Check access separately.
  • Sharing without a fallback: Some viewers ignore fragments. Include a page number or section name in your instructions.

Best Practices

  • Use clear, stable IDs for headings on pages you manage.
  • Copy the full link and check that the destination opens as intended.
  • Confirm public access from a signed-out session when the document is meant for anyone to read.
  • For PDFs, test the actual hosted link and tell readers the page or section in plain language.
  • Keep a fallback instruction with the link so readers can still find the content if the deep link fails.

Conclusion

For a web page, a matching heading id and URL fragment make a direct section link. For a PDF, a page fragment may work, but viewer behavior is not uniform. Test the complete public link and give readers a page or section fallback.

References

No external sources were consulted for this article. The examples are presented as common URL patterns, and the PDF behavior should be verified in the viewer and hosting setup you use.

What would your domain sell for?

A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.