1. Introduction
Efficiently rendering a website relies on the user agent being able to detect what parts of the page are being displayed, which parts might affect the currently-displayed section, and what can be ignored.
There are various heuristics that can be used to guess when a given sub-tree is independent of the rest of the page in some manner, but they’re fragile, so innocuous changes to a page may inadvertently make it fail such heuristic tests, causing rendering to fall into a slow code path. There are also many things that would be good to isolate which are difficult or impossible to detect in a heuristic manner.
To alleviate these problems and allow strong, predictable isolation of a subtree from the rest of the page, this specification defines a contain property.
To allow even further optimization of off-screen contents, this spec also defines a content-visibility property, enabling the user agent to skip an element’s layout and painting entirely when not needed.
1.1. Module Interactions
This document defines new features not present in earlier specifications. In addition, it aims to replace and supersede [CSS-CONTAIN-1] once stable.
1.2. Value Definitions
This specification follows the CSS property definition conventions from [CSS2] using the value definition syntax from [CSS-VALUES-3]. Value types not defined in this specification are defined in CSS Values & Units [CSS-VALUES-3]. Combination with other CSS modules may expand the definitions of these value types.
In addition to the property-specific values listed in their definitions, all properties defined in this specification also accept the CSS-wide keywords as their property value. For readability they have not been repeated explicitly.
2. Strong Containment: the contain property
Tests
The following tests are crash tests that relate to general usage of this feature but are not particularly tied to any particular normative statement.
- contain-chrome-thcrash-001.html (live test) (source)
- contain-crash.html (live test) (source)
- contain-flexbox-outline.html (live test) (source)
- contain-nested-crash-001.html (live test) (source)
- contain-nested-crash-002.html (live test) (source)
- contain-nested-crash-003.html (live test) (source)
- contain-nested-crash-004.html (live test) (source)
- contain-nested-relayout-boundary.html (live test) (source)
- quote-scoping-shadow-dom-crash.html (live test) (source)
- contain-style-remove-element-crash.html (live test) (source)
| Name: | contain |
|---|---|
| Value: | none | strict | content | [ [size | inline-size] || layout || style || paint ] |
| Initial: | none |