Element.scrollTop property gets or sets the number of pixels that an element's content is scrolled vertically.
scrollTop value is a measurement of the distance from the element's top to its topmost visible content. When an element's content does not generate a vertical scrollbar, then its
scrollTop value is
scrollTop can be set to any integer value, with certain caveats:
- If the element can't be scrolled (e.g. it has no overflow or if the element has a property of "non-scrollable"),
scrollTopdoesn't respond to negative values; instead, it sets itself back to
- If set to a value greater than the maximum available for the element,
scrollTopsettles itself to the maximum value.
scrollTop is used on the root element (the
<html> element), the
scrollY of the window is returned. This is a special case of
Warning: On systems using display scaling,
scrollTop may give you a decimal value.