A CSS property you might not know

spO0q 🐒🎃 - Dec 9 '20 - - Dev Community

Today I learned the existence of scroll-margin, which I've missed from the beginning.

Browser support is not ideal (especially ios and also old browsers) but decent.

Source: caniuse

If you have any anchor in your page, it's nice to set something like:

.myanchor {
    scroll-margin-top: 73px;
}
Enter fullscreen mode Exit fullscreen mode

This way, the top screen does not eat your anchor title ^^

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .