Skip to content

[css-contain] Computed value of shortcut values #5511

@Loirooriol

Description

@Loirooriol

contain has 2 shortcut values, strict and content:

strict: This value turns on all forms of containment except style containment for the element. In other words, it behaves the same as contain: size layout paint;.
content: This value turns on all forms of containment except size containment and style containment for the element. In other words, it behaves the same as contain: layout paint;.

But do they compute to themselves, or do they compute to the expanded list of values?

document.documentElement.style.contain = "content";
getComputedStyle(document.documentElement).contain;
// "content" in both Chromium and Firefox

document.documentElement.style.contain = "layout paint";
getComputedStyle(document.documentElement).contain;
// "content" in Chromium, "layout paint" in Firefox

So Chromium expands the shortcuts in the computed value, and when serializing it uses the shortest serialization principle

If component values can be omitted or replaced with a shorter representation without changing the meaning of the value, omit/replace them.

And in Firefox the specified value computes as-is, so content and layout paint are considered to be different values that just happen to produce the same behavior.

Who is correct? Firefox obeys "Computed value: specified keyword(s)", but "[contain: content] behaves the same as contain: layout paint;" could be understood to mean that they have the same computed value.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions