Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Positioning and Stacking

The position-visibility property

Reference for the CSS position-visibility property: hide an anchored element when its anchor scrolls out of view or it overflows. Limited browser support.

The position-visibility property controls whether an anchored element stays visible when its anchor is no longer visible, for example after the anchor scrolls out of a scroll container. Without it, a tooltip can end up floating over unrelated content once its trigger has gone.

Limited support: this is a recent part of anchor positioning, so treat it as a progressive enhancement.

CSS
.tooltip {
  position-visibility: anchors-visible;
}

Try it

Anchor scrolled out of view

Syntax

CSS
position-visibility: always | [ anchors-visible || no-overflow ];
  • Initial value: anchors-visible
  • Applies to: absolutely positioned boxes
  • Inherited: no
  • Animatable: no (discrete)
  • Computed value: as specified

Values

Value Description
anchors-visible Hide the element when its anchor is completely hidden (clipped by an ancestor or scrolled out). This is the initial value.
no-overflow Hide the element if it overflows its containing block, even after fallbacks were tried.
always Never hide the element because of anchoring.

Usage notes

  • "Hidden" works like visibility: hidden: the box is not drawn, but it still takes part in layout.
  • Check the default. Because anchors-visible is already the default, this property is most useful to opt out with always or to add no-overflow.
  • Do not hide essential UI. If the content must stay reachable, as with an open dialog, use always.
  • Pairs with fallbacks: try position-try-fallbacks first; no-overflow only hides what still does not fit.

Browser support

Limited. Chromium browsers support it; other engines have been slower to ship. Check a current compatibility table and make sure the page still works when the property is ignored.