Leave space above headings when visitors jump to them, so a fixed or sticky header doesn't hide them.
:target,
h1[id],
h2[id],
h3[id],
h4[id] {
/* The height of your sticky header, plus a little breathing room. */
scroll-margin-top: 100px;
}
With a sticky header, clicking a table of contents link or opening a URL with a #section scrolls the heading right to the top of the window, where the header covers it. This CSS fixes that.
scroll-margin-top adds an offset to an element whenever the browser scrolls it into view. It works for anchor links, #hash URLs, and scripts using scrollIntoView(). The rule applies to headings with an id, which are what tables of contents link to, and to whatever the current URL’s hash points at.
.admin-bar :target { scroll-margin-top: 132px; } for that.Open a post with a table of contents and click a link. The heading should land just below the header, fully visible.