blog

Add scroll margin on pages with fixed header

Something I learned from Andy Bell’s CSS reset

/* Anything that has been anchored to should have extra scroll margin */
:target {
scroll-margin-block: 5ex;
}

It’s a great way to account for fixed headers when using anchor links. Came in handy on Hugo’s legal page which features TOC for privacy policy and a fixed header.