Dev Helpers
← Back

Give scroll targets an extra margin

Give scroll targets an extra margin with Tailwind CSS 4 utilities. The preview uses precompiled styles.

Open this example in the interactive library

Source code

<div class="demo overflow-auto h-24 [&_#end]:scroll-mt-4">
  <a href="#end">Jump to heading</a>
  <p style="height: 8rem">Scrollable content</p>
  <p id="end" style="min-height: 5rem">Target with top margin</p>
</div>