Dev Helpers
← Back

Target an anchor with breathing room

Target an anchor with breathing room with native CSS. The preview includes a small shared demo stylesheet.

Open this example in the interactive library

Source code

<style>
  .demo {
    overflow-y: auto;
    scroll-padding-top: 1rem;
    height: 6rem;
  }
</style>
<div class="demo">
  <a href="#end">Jump to end</a>
  <p style="height: 8rem">Scrollable content</p>
  <p id="end" style="min-height: 5rem">Target with top padding</p>
</div>