← Back to release summary

HTMLElement.scrollParent

Category
Miscellaneous
Type
New or changed feature
Status
Proposed (Chrome Proposed)
Intent stage
None

Summary

The scrollParent attribute on HTMLElement returns the nearest scroll container containing block of the element's. In particular this is the nearest scroll container whose scroll offset affects the element's position. This can be useful to jump to elements to scroll or to elements on which to add scroll listeners to detect when the user scrolls.

Motivation

Developers have to check a number of conditions to determine if an element is a scroll container and correctly walking the containing block chain can be tricky to get correct. Having scrollParent will allow developers to jump right to the correct container on which to add scroll event listeners and/or call scrolling API's in order to effect the target element's scroll position or use those scrolling offsets on other elements.

Standards & signals

Ecosystem

View on chromestatus.com