content-visibility Rendering Deferral, Containment and Searchable Hidden Content
How to defer off-screen rendering with content-visibility, pair contain-intrinsic-size, and keep collapsed content findable with hidden=until-found and details.
This page summarizes Chrome for Developers guidance on the CSS content-visibility property, its companion contain-intrinsic-size, and HTML patterns (hidden="until-found", <details>) that hide content visually without breaking find-in-page, deep links, or assistive technology. The techniques apply to long pages, SPAs, complex dashboards, and custom accordions.
content-visibility: what it does and when people need it
Section titled “content-visibility: what it does and when people need it”content-visibility tells the browser it may skip layout and paint work for an element’s subtree until that work is needed—either because the user is about to see the content or because you reveal a hidden view. Pages with infinite scroll, dense articles, Kanban boards, or multi-tab SPAs are typical situations where teams search for “defer rendering” or “reduce layout cost” without removing nodes from the DOM.
Web pages with extensive content—such as infinite scrolls, complex dashboards, or dense articles can suffer from slow initial rendering and sluggish interactions. Modern web technologies allow you to defer the rendering workload for content that is not immediately visible, significantly boosting performance without breaking accessibility or user expectations.
— Chrome for Developers, Defer rendering heavy content
The same property appears across several focused guides: deferring heavy below-the-fold sections, pausing background work when rendering stops, caching inactive SPA views, and isolating reflow in complex layouts. Broader DOs and DON’Ts live in the Performance hub.
content-visibility: auto vs hidden vs visible
Section titled “content-visibility: auto vs hidden vs visible”| Scenario | Value | Main benefit |
|---|---|---|
| Large blocks strictly below the initial fold | content-visibility: auto |
Browser defers layout/paint until the container nears the viewport |
| Initially hidden panels you toggle often (tabs, extra table rows) | content-visibility: hidden |
Skips layout for hidden subtrees but keeps cached rendering state for fast reveal |
| User should see the subtree | visible (or remove the property) |
Normal rendering |
While both aid performance, they serve distinct use cases.
— Chrome for Developers, Defer rendering heavy content
For searchable collapsed content where native find-in-page must still work, prefer hidden="until-found" or <details>—not content-visibility: hidden alone (see below).
content-visibility: auto — defer below-the-fold rendering
Section titled “content-visibility: auto — defer below-the-fold rendering”content-visibility: auto is for large, self-contained blocks that are off-screen on first paint, such as trailing comments, feed cards, or bottom-heavy sections.
DO target large, self-contained layout blocks that are strictly below the initial fold (e.g., card items in an infinite feed, trailing comments, or bottom-heavy layout sections).
— Chrome for Developers, Defer rendering heavy content
DO NOT apply this property to elements within the initial, above-the-fold viewport. Doing so forces the browser to evaluate visibility boundaries before rendering, which paradoxically delays critical page load performance.
— Chrome for Developers, Defer rendering heavy content
DON’T apply content-visibility: auto on smaller, simpler pages: The gains will be negligible and there are risks of side effects with content jumping.
— Chrome for Developers, Performance
How to apply content-visibility: auto on off-screen sections
Section titled “How to apply content-visibility: auto on off-screen sections”-
Confirm each target section is not in the initial viewport on load (Defer rendering heavy content).
-
Set
content-visibility: autoon those containers. -
Always set
contain-intrinsic-sizeon the same element (next section). -
Run keyboard-only sequential navigation tests after rollout (accessibility note).
Example pattern from the defer-rendering guide:
/* Apply only outside the initial layout viewport */.heavy-section-deferred { content-visibility: auto; contain-intrinsic-size: auto none auto 150px;}Prefer intrinsic estimates tied to real typography when you can:
DO derive contain-intrinsic-size from the content: When setting contain-intrinsic-size use the auto keyword and a value that’s derived from what is known about the contents (i.e. text size, spacing, size of graphics, character count). Preferably use units such as rem, lh, cap, or ch that match values used for the elements within the contents rather than px.
— Chrome for Developers, Performance
contain-intrinsic-size: stop layout shift when content is skipped
Section titled “contain-intrinsic-size: stop layout shift when content is skipped”Pairing is mandatory for content-visibility: auto. Without a placeholder size, skipped elements collapse to zero height and the scrollbar jumps when the browser renders them.
MANDATORY: You MUST pair content-visibility: auto with contain-intrinsic-size. Failure to do so forces the browser to collapse the element to a 0px height when off-screen, causing severe layout shifting and scrollbar jumping as the user scrolls.
— Chrome for Developers, Defer rendering heavy content
The auto keyword lets the browser remember the rendered size for later skip passes:
Using the auto keyword enables the browser to “remember” the exact size once the element is finally rendered, using that calculated size over the placeholder if the element goes off-screen again.
— Chrome for Developers, Defer rendering heavy content
content-visibility: hidden — fast view toggles and SPA tab caching
Section titled “content-visibility: hidden — fast view toggles and SPA tab caching”Use content-visibility: hidden when heavy UI is logically hidden but you want to avoid destroying DOM state—common for SPA tab strips or large data tables with extra rows.
Identify heavy sections: Locate layout blocks that are initially hidden (e.g., extra rows in a large data table). Apply CSS: Add content-visibility: hidden to the element. Reveal the element: When the element should be revealed, change the content-visibility property to visible or auto.
— Chrome for Developers, Defer rendering heavy content
For SPAs, inactive views can stay in memory with cached paint/layout state:
By using content-visibility: hidden on inactive views, the browser removes the element’s contents from the layout flow and stops painting it, but retains its cached rendering state in memory. When the user switches back, the view restores nearly instantly.
— Chrome for Developers, Faster SPA View Transitions via State Caching
Because content-visibility: hidden excludes the element and its children from the accessibility tree and find-in-page search, DO NOT use it if the content must remain discoverable while hidden.
— Chrome for Developers, Defer rendering heavy content
Note that content-visibility: hidden on a view container still paints the element’s own box (background, border, padding):
The content-visibility: hidden property hides an element’s contents, but the element itself remains styled and visible.
— Chrome for Developers, Faster SPA View Transitions via State Caching
content-visibility: auto on visible regions — layout containment for interactions
Section titled “content-visibility: auto on visible regions — layout containment for interactions”On complex pages, content-visibility: auto on on-screen columns or widgets does not skip paint; the win is automatic layout, style, and paint containment so local DOM changes do not reflow the whole page.
For visible elements, the browser does not skip rendering. Instead, the performance benefit comes entirely from the CSS containments that the property automatically enforces (i.e., layout, style, and paint). This containment acts as a boundary.
— Chrome for Developers, Optimizing Interactions in Complex Layouts
Apply it to self-contained units (Kanban columns, grid regions) with contain-intrinsic-size sized to the column. For widgets that only need isolation without skip rendering, explicit contain: layout style paint is also documented in Performance.
Related main-thread advice: reduce geometry writes before reads and avoid long forced reflows (Forced reflow, Minimize main thread work). Very large DOMs still need structural fixes such as virtual scrolling for long lists (Optimize DOM size).
contentvisibilityautostatechange: pause canvas, WebGL, or polling when skipped
Section titled “contentvisibilityautostatechange: pause canvas, WebGL, or polling when skipped”When an element uses content-visibility: auto, the browser fires contentvisibilityautostatechange when it starts or stops skipping rendering—often before the element enters the viewport (pre-render margin).
By listening to this event, you can pause expensive operations like
<canvas>animations, WebGL rendering, or high-frequency WebSocket data polling when they are not needed, and resume them just-in-time when the browser prepares to display the content.— Chrome for Developers, Efficient Background Processing
| API | Use when |
|---|---|
IntersectionObserver |
App logic tied to visual viewport intersection (lazy load, infinite-scroll triggers) |
contentvisibilityautostatechange |
Rendering-heavy work tied to the browser’s internal skip/resume lifecycle |
Use IntersectionObserver for application logic tied to the exact visual visibility of an element in the viewport (e.g., lazy-loading data, infinite scroll triggers). Use contentvisibilityautostatechange for rendering-heavy work (like complex canvas updates or heavy DOM mutations).
— Chrome for Developers, Efficient Background Processing
Attach the listener on the element that has content-visibility: auto, or use a capturing listener on a parent— the event does not bubble in some implementations (Efficient Background Processing). In unsupported browsers, fall back to IntersectionObserver with rootMargin if you still need pausing.
Searchable hidden content: details, hidden=“until-found”, exclusive accordion
Section titled “Searchable hidden content: details, hidden=“until-found”, exclusive accordion”Hiding with display: none or visibility: hidden removes content from find-in-page and breaks scroll-to-text fragments. Chrome documents two primary patterns in Search hidden content and Making collapsed content accessible with hidden=until-found.
Prefer <details> for simple disclosures
Section titled “Prefer <details> for simple disclosures”The
<details>element has searchable and accessible text by default, and no special implementation is required. Prefer using<details>over hidden=“until-found” if possible.— Chrome for Developers, Search hidden content
Exclusive accordion: one open panel with the name attribute
Section titled “Exclusive accordion: one open panel with the name attribute”For “only one open at a time,” give sibling <details> elements the same name value (they need not be adjacent in the DOM):
<details name="faq"> <summary>Item 1</summary> <p>Contents...</p></details><details name="faq"> <summary>Item 2</summary> <p>Contents...</p></details>When you open one of the
<details>elements from the group, the previously opened one will automatically close.— Chrome for Developers, Exclusive Accordion
See also the HTML and CSS and UI overviews.
When to use hidden=“until-found” instead of details
Section titled “When to use hidden=“until-found” instead of details”Use hidden="until-found" when styling or controls are custom, toggles live elsewhere in the DOM, or you do not want re-hiding after reveal (Search hidden content).
By adding hidden=until-found to the container for your hidden content, you make it possible for the browser to search text in that hidden region, and reveal the section if a match is found.
— Chrome for Developers, Making collapsed content accessible with hidden=until-found
Synchronize UI when find-in-page opens a panel: listen for beforematch on the element (or delegate from a parent). For mutually exclusive custom accordions, reset other panels and aria-expanded in that handler (Search hidden content).
Implementation rules:
- Do not put
display: noneorvisibility: hiddenon the same node ashidden="until-found"(Search hidden content). - Put borders/padding on inner wrappers; the hidden container may still generate a box (hidden=until-found).
- Do not use it for secrets, tokens, or screen-reader-only text (Search hidden content).
- Ensure content is revealable without find-in-page for users on browsers without support; feature-detect via
'onbeforematch' in HTMLElement.prototype(hidden=until-found).
hidden="until-found" applies content-visibility: hidden under the hood rather than display: none, which enables search while collapsed (hidden=until-found).
Accessibility, fallbacks, and common mistakes
Section titled “Accessibility, fallbacks, and common mistakes”Keyboard and AT with content-visibility: auto: off-screen nodes may be excluded from sequential focus routes until focus moves inside them—verify linear keyboard navigation (Defer rendering heavy content). content-visibility: auto keeps nodes in the DOM for screen readers in many cases; use aria-hidden deliberately when content must be hidden from AT (Performance).
Unsupported content-visibility: the property is ignored; content-visibility: hidden without a fallback can leave hidden views fully visible—use @supports and display: none where needed (Defer rendering heavy content, Faster SPA View Transitions via State Caching).
Manual containment fallback: @supports not (content-visibility: auto) { contain: layout style paint; } on layout regions (Optimizing Interactions in Complex Layouts).
Common mistakes to avoid:
content-visibility: autoon above-the-fold or tiny pages.contain-intrinsic-sizeomitted → scrollbar jump and CLS.content-visibility: hiddenon content that must stay findable with Ctrl+F.hidden="until-found"combined with display-hiding CSS.- Caching unlimited SPA views without memory limits.
- Global
will-changeeverywhere (VRAM cost) per Performance.
For motion and broader CSS architecture, CSS: Modern Architecture points to Motion and Performance sections separately.
How to check this on your site
Section titled “How to check this on your site”-
Load a long or tabbed page in Chrome DevTools Performance panel and confirm below-the-fold sections or inactive tabs do not trigger full-document layout when toggled or scrolled (Optimizing Interactions in Complex Layouts).
-
Scroll through deferred sections and watch for scrollbar jumps or large layout shifts; adjust
contain-intrinsic-sizeestimates if shifts appear (Defer rendering heavy content). -
Tab through the page with the keyboard only, including into off-screen
content-visibility: autoregions, and fix focus order if sections are unreachable (Defer rendering heavy content). -
Use find-in-page on collapsed FAQ or accordion content and confirm matches reveal the right panel; test custom accordions with
beforematchhandlers (Search hidden content). -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact sentence you are asking about, and we will correct or clarify it.