HLLL
HLLL

Reputation: 3771

Should the scroll-behavior, overflow-anchor and overflow-y CSS properties be set on html or body?

I want to always show the scrollbar, have smooth scrolling enabled for the entire page and disable the new overflow-anchor functionality.

Is this best set on the html tag:

html {
    overflow-y: scroll;
    scroll-behavior: smooth;
    overflow-anchor: none;
}

or on the body tag?

body {
    overflow-y: scroll;
    scroll-behavior: smooth;
    overflow-anchor: none;
}

Please explain which is preferred and why. Thank you!

Upvotes: 0

Views: 597

Answers (1)

Hiren Vaghasiya
Hiren Vaghasiya

Reputation: 5544

Add scroll-behavior: smooth to the html element to enable smooth scrolling for the whole page (note: it is also possible to add it to a specific element/scroll container)

You can get refrence form Here and info about browser compatibility also

and overflow-anchor property can be applied to all elements

Upvotes: 1

Related Questions