Favorites

CSS position-visibility Property

position-visibility
CSS PropertyThis property is supported by all modern browsers.
Updated 22nd November 2026

The position-visibility property hides an anchor-positioned element when its anchor is hidden or when it overflows.

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee

Description

The position-visibility property decides when an absolutely positioned element should be hidden automatically, typically an anchored tooltip or popup whose anchor has scrolled out of view. Hiding is done strongly, as with visibility: hidden, without changing the element's layout.

With anchors-visible (the default) the element is hidden when its default anchor is completely clipped, for example scrolled out of a scroll container, so labels do not float detached from the content they describe. no-overflow hides the element when it overflows its containing block even after trying all fallbacks. always never hides it.

Definition

Initial value
anchors-visible
Applies to
absolutely positioned elements
Inherited
no
Computed value
as specified
Animatable
discrete
JavaScript syntax
object.style.positionVisibility

Interactive Demo

Scroll this box until the anchor is out of view.

Anchor

More content

More content

More content

More content

More content

More content

More content

More content

Tooltip
Demo Code
HTML Code
<div class="demo-area">
	<div class="demo-scroll">
		<p>Scroll this box until the anchor is out of view.</p>
		<div class="demo-f">Anchor</div>
		<p>More content</p>
		<p>More content</p>
		<p>More content</p>
		<p>More content</p>
		<p>More content</p>
		<p>More content</p>
		<p>More content</p>
		<p>More content</p>
		</div>
	<div class="demo-element">Tooltip</div>
</div>
CSS Code
.demo-area {
	position: relative;
	width: 300px;
}
.demo-scroll {
	width: 150px;
	height: 170px;
	overflow: auto;
	background: #f4f4f4;
	outline: 1px dashed #b0b0b0;
	font-size: 13px;
}
.demo-scroll p {
	margin: 8px;
	color: #666;
}
.demo-f {
	anchor-name: --demo-f;
	margin: 8px;
	padding: 6px;
	background: #e7ecff;
	border: 2px solid #4361ee;
}
.demo-element {
	position: absolute;
	margin: 4px;
	padding: 4px 8px;
	background: #f72585;
	color: #fff;
	font-size: 13px;
	white-space: nowrap;
	position-anchor: --demo-f;
	position-area: right;
	position-visibility: always;
}

Syntax

position-visibility: always | [ anchors-valid || anchors-visible || no-overflow ];

Values

  • alwaysThe element is always shown.
  • anchors-visibleThe default. The element is hidden when its default anchor is completely hidden by clipping or scrolling.
  • anchors-validThe element is hidden when any of its required anchors cannot be found.
  • no-overflowThe element is hidden when it overflows its containing block after all fallback positions have been tried.
  • initialSets the property to its initial value.
  • inheritTakes the computed value of the parent element.

Example

<div class="scroller">
<span class="anchor">Scroll me out of view</span>
<span class="label">I disappear with my anchor</span>
</div>
.scroller {
  height: 150px;
  overflow: auto;
  border: 1px solid #ccc;
  font-family: system-ui, sans-serif;
  position: relative;
}

.anchor {
  anchor-name: --target;
  margin: 40px 20px 400px;
  padding: 8px 12px;
  background: #e7ecff;
  display: inline-block;
}

.label {
  position: fixed;
  position-anchor: --target;
  position-area: right;
  position-visibility: anchors-visible; /* hide when the anchor scrolls away */
  margin-left: 8px;
  padding: 4px 8px;
  background: #f72585;
  color: #fff;
  border-radius: 4px;
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS position-visibility property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee