Inspect CSS Contain Intrinsic Size Safari Web Inspector
In this article
Yes, Safari's Web Inspector can inspect CSS contain and content-visibility properties, including the intrinsic size (the size the element would have without containment). You can see these properties in the Styles pane, and the Computed pane shows their resolved values. However, Safari does not visually overlay the intrinsic size box like some other tools; you must infer it from the computed values or by temporarily disabling containment.
Background: What Are contain and content-visibility?
The CSS contain property tells the browser that an element's layout, style, paint, or size is independent of its contents. This allows the browser to skip work when the element changes, improving performance. The content-visibility property (which implies contain: layout style paint) lets the browser skip rendering off-screen elements entirely. When an element has content-visibility: auto, it needs an intrinsic size (often set via contain-intrinsic-size) so the page doesn't jump when the element scrolls into view. Safari supports both properties since version 15.4 (2022).
How Safari's Web Inspector Displays These Properties
When you inspect an element with contain or content-visibility, the Styles pane shows the declarations exactly as written in your CSS. The Computed pane lists the resolved values (e.g., contain: layout paint style). For contain-intrinsic-size, the Computed pane shows the specified size (e.g., auto 500px). Safari does not draw an overlay or a dashed box around the intrinsic size; you have to read the numbers. You can also use the "Filter" field in the Computed pane to quickly find these properties.
How to Inspect the Intrinsic Size Effectively
- Open Web Inspector (right-click → Inspect Element, or Cmd+Option+I).
- Select the element with
content-visibilityorcontain. - Go to the Computed pane and type "contain" in the filter to see all related properties.
- Note the
contain-intrinsic-sizevalue. If it saysauto 500px, the intrinsic size is 500px (the auto keyword means the browser remembers the last rendered size). - To see the actual rendered size, look at the Metrics pane (or the box model diagram) – that shows the current size, which may differ from the intrinsic size if the element is off-screen.
- To verify the intrinsic size is being used, you can temporarily disable
content-visibilityin the Styles pane by unchecking the declaration, then observe the layout shift.
Common Problems and Misconceptions
A frequent misconception is that contain-intrinsic-size sets the actual size of the element. It does not – it only provides a placeholder size when the element is not rendered. Another issue: if you set contain-intrinsic-size but the element's content is larger, the element will grow to fit the content when rendered. In Safari, if you don't set an intrinsic size, the element may collapse to 0 height when off-screen, causing scrollbar jumps. The Web Inspector won't warn you about this; you have to check the computed values yourself.
Comparing with Chrome DevTools
Chrome DevTools has a dedicated "Rendering" tab where you can enable "Show intrinsic size" overlays for content-visibility elements. Safari lacks this visual aid. However, Safari's Computed pane gives the same information. If you are debugging cross-browser, you may need to switch to Chrome to see the overlay, but the underlying CSS behavior is identical. Safari also supports contain-intrinsic-size: auto none (to disable the remembered size) as of recent versions.
Practical Tips for Using Containment in Safari
- Always set
contain-intrinsic-sizewhen usingcontent-visibility: autoto avoid layout shift. - Use
contain: layout style paintinstead ofcontent-visibilityif you don't need the size hint. - Test in Safari's Technology Preview to get the latest fixes.
- Combine with
content-visibility: hiddenfor off-screen content that you want to keep in the DOM but not render. - Remember that
contain: sizealone requires you to set an explicit size; otherwise the element will collapse.
Frequently Asked Questions
Does Safari support contain-intrinsic-size?
Yes, Safari supports contain-intrinsic-size since version 15.4. You can use the longhand properties (contain-intrinsic-width and contain-intrinsic-height) or the shorthand. The Web Inspector will show them in the Computed pane.
Why does my element jump when scrolling in Safari?
This usually happens because you have content-visibility: auto without an intrinsic size. The browser reserves 0 space until the element is scrolled into view, causing the scrollbar to shift. Add contain-intrinsic-size (e.g., contain-intrinsic-size: 500px) to fix it.
Can I see the intrinsic size in the box model diagram?
No, the box model diagram shows the actual rendered size, not the intrinsic size. To see the intrinsic size, check the Computed pane for contain-intrinsic-size.
How do I temporarily disable containment in the inspector?
In the Styles pane, you can uncheck the checkbox next to the contain or content-visibility declaration. This will remove the property and let you see how the element behaves without it.
Is content-visibility safe to use on all elements?
It is safe on elements that are not expected to be searched or focused when off-screen. Avoid it on elements that contain focusable content or that rely on find-in-page (browser search) because the browser may not find text inside hidden content. Safari's implementation respects these concerns, but it's best to test.