Favorites

CSS content-visibility Property

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

The content-visibility property lets the browser skip rendering an element's content until it is needed, such as when it scrolls into view, speeding up page loads.

☕
Enjoying this site?

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

Buy us a coffee

Description

The content-visibility property lets the browser skip rendering an element's contents until they are needed. It is one of the most effective performance tools for long pages: with content-visibility: auto, sections that are far off-screen are not laid out or painted, which can cut the initial rendering time of large documents dramatically.

When the contents are skipped the element behaves as if it had size containment, so it would collapse to zero height. Pair it with contain-intrinsic-size (for example contain-intrinsic-size: auto 500px) to reserve a placeholder size and keep the scrollbar stable. Skipped content stays in the DOM and remains available to find-in-page, links to fragments and assistive technology when the value is auto.

hidden skips the contents completely, like display: none but keeping the rendering state cached, which makes it fast to show again. The property can be animated with transition-behavior allow-discrete.

Definition

Initial value
visible
Applies to
elements for which size containment can apply
Inherited
no
Computed value
as specified
Animatable
discrete
JavaScript syntax
object.style.contentVisibility

Interactive Demo

The contents of this box: some text and a badge.
Badge
Demo Code
HTML Code
<div class="demo-element">
	The contents of this box: some text and a badge.<br>
	<span>Badge</span>
</div>
CSS Code
.demo-element span {
	display: inline-block;
	margin-top: 8px;
	padding: 4px 10px;
	background: #f72585;
	color: #fff;
}
.demo-element {
	width: 240px;
	min-height: 60px;
	padding: 14px;
	background: #e7ecff;
	border: 2px solid #4361ee;
	font-size: 15px;
	content-visibility: visible;
}

Syntax

content-visibility: visible | auto | hidden;

Values

  • visibleThe default. The contents are rendered normally.
  • autoThe element gets layout, style and paint containment. If it is not relevant to the user (far off-screen, not focused, not selected), its contents are skipped. They remain searchable and accessible.
  • hiddenThe element's contents are skipped entirely and are not accessible to find-in-page, tab order or accessibility tools, but their rendering state can be cached.
  • initialSets the property to its initial value.
  • inheritTakes the computed value of the parent element.

Example

<div class="section"><h3>Section 1</h3><p>Rendered when near the viewport.</p></div>
<div class="section"><h3>Section 2</h3><p>Off-screen sections are skipped until you scroll to them.</p></div>
<div class="section"><h3>Section 3</h3><p>The placeholder size keeps the scrollbar stable.</p></div>
<div class="hidden-box"><p>You cannot see this text.</p></div>
.section {
  content-visibility: auto;              /* skip rendering when off-screen */
  contain-intrinsic-size: auto 200px;    /* placeholder height */
  margin: 0 0 16px;
  padding: 16px;
  background: #f1f3ff;
  border-radius: 8px;
  font-family: system-ui, sans-serif;
}

.hidden-box {
  content-visibility: hidden;            /* contents not rendered at all */
  height: 40px;
  border: 1px dashed #999;
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS content-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