CSS overflow-anchor Property

If this site has been useful, we’d love your support! Running this site takes time and resources, and every small contribution helps us keep creating valuable content. Consider buying us a coffee to keep things going strong!

Description

The overflow-anchor CSS property is used to control how an element should behave when it is partially scrolled out of view within a scrolling container. When set to "auto," which is the default value, the browser determines whether the element should remain anchored and not scroll away completely, making it partially visible even when the user scrolls. This property is particularly useful for improving user experience when dealing with long lists or tables, ensuring that important elements stay in view and accessible as users scroll through content. It helps prevent abrupt shifts in layout and enhances the overall usability of a webpage.

Initial value
auto
Applies to
all elements
Inherited
no
Computed value
as specified
Animatable
discrete
JavaScript syntax
object.style.overflowAnchor

Syntax

overflow-anchor: auto | none

Values

  • autoThe element becomes a potential anchor when adjusting scroll position.
  • noneThe element won't be selected as a potential anchor.

Example

* {
  overflow-anchor: none;
}

Browser Support

The following table will show you the current browser support for the CSS overflow-anchor property.

Desktop
Edge Chrome Firefox Opera Safari
79566643x
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
566643x656

Last updated by CSSPortal on: 31st December 2023