Skip to content

Note that container style queries only support custom properties - #45709

Open
RizgarOzan wants to merge 4 commits into
mdn:mainfrom
RizgarOzan:fix-style-query-custom-properties-only
Open

RizgarOzan wants to merge 4 commits into
mdn:mainfrom
RizgarOzan:fix-style-query-custom-properties-only

Conversation

@RizgarOzan

Copy link
Copy Markdown
Contributor

Description

The Firefox 151 release notes said @container style() queries let you check "a valid CSS declaration, a CSS property, or a custom property", and the @container reference shows style(background-color: red) / style(color: green) examples with no caveat. No browser supports style features other than custom properties. This updates the release note entry and adds a note to the @container style query section, linking to the guide section that already covers this.

Motivation

CSS Conditional 5 §6.2 allows any supported CSS property as a style feature, but every engine only implements custom properties, so readers copying the reference examples get queries that never match.

Additional details

Checked in Chromium (headless Edge 153): a container with --x: 1; color: rgb(0, 128, 0); display: block; border: 2px solid red, where every query below is true per the spec:

style(--x: 1)                         matches=true
style(--x)                            matches=true
style(color: rgb(0, 128, 0))          matches=false
style(color: green)                   matches=false
style(display: block)                 matches=false
style(color)                          matches=false
not style(background-color: red)      matches=false
style(border: 2px solid red)          matches=false

All of them parse (the conditionText is kept); they just never match.

Not tested in Firefox or Safari, but their parsers only accept custom property names:

The containment guide already states this limitation in several places, so I left it unchanged.

Lint on the changed files: markdownlint-cli2 (repo config) 0 issues, prettier clean, cspell 0 issues.

Related issues and pull requests

Fixes #44701

@RizgarOzan
RizgarOzan requested review from a team as code owners September 14, 2026 17:15
@RizgarOzan
RizgarOzan requested review from dipikabh and estelle and removed request for a team September 14, 2026 17:16
@github-actions github-actions Bot added Content:CSS Cascading Style Sheets docs Content:Firefox Content in the Mozilla/Firefox subtree size/s [PR only] 6-50 LoC changed labels Sep 14, 2026
@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Preview URLs (2 pages)

External URLs (4)

URL: /en-US/docs/Mozilla/Firefox/Releases/151
Title: Firefox 151 release notes for developers

(comment last updated: 2026-09-22 14:32:50)

@Josh-Cena
Josh-Cena requested a review from dletorey September 14, 2026 18:02
@RizgarOzan

Copy link
Copy Markdown
Contributor Author

Friendly ping - let me know if the wording should be adjusted.

@dletorey

Copy link
Copy Markdown
Contributor

Friendly ping - let me know if the wording should be adjusted.

I shall be doing this tomorrow, thanks for the prod.

@dletorey dletorey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

### CSS

- The [`@container`](/en-US/docs/Web/CSS/Reference/At-rules/@container) CSS at-rule supports [`style()`](/en-US/docs/Web/CSS/Guides/Containment/Container_size_and_style_queries#container_style_queries) queries. This allows you to check if a container has a valid CSS declaration, a CSS property, or a custom property, and apply styles to its children accordingly. ([Firefox bug 2016929](https://bugzil.la/2016929), ([Firefox bug 2019254](https://bugzil.la/2019254)), ([Firefox bug 2024601](https://bugzil.la/2024601)), [Firefox bug 2030645](https://bugzil.la/2030645)).
- The [`@container`](/en-US/docs/Web/CSS/Reference/At-rules/@container) CSS at-rule supports [`style()`](/en-US/docs/Web/CSS/Guides/Containment/Container_size_and_style_queries#container_style_queries) queries. This allows you to check if a container has a custom property, optionally with a specific value, and apply styles to its children accordingly. As in other browsers, only custom properties are supported; queries for regular CSS properties, such as `style(color: green)`, never match. ([Firefox bug 2016929](https://bugzil.la/2016929), ([Firefox bug 2019254](https://bugzil.la/2019254)), ([Firefox bug 2024601](https://bugzil.la/2024601)), [Firefox bug 2030645](https://bugzil.la/2030645)).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The [`@container`](/en-US/docs/Web/CSS/Reference/At-rules/@container) CSS at-rule supports [`style()`](/en-US/docs/Web/CSS/Guides/Containment/Container_size_and_style_queries#container_style_queries) queries. This allows you to check if a container has a custom property, optionally with a specific value, and apply styles to its children accordingly. As in other browsers, only custom properties are supported; queries for regular CSS properties, such as `style(color: green)`, never match. ([Firefox bug 2016929](https://bugzil.la/2016929), ([Firefox bug 2019254](https://bugzil.la/2019254)), ([Firefox bug 2024601](https://bugzil.la/2024601)), [Firefox bug 2030645](https://bugzil.la/2030645)).
- The [`@container`](/en-US/docs/Web/CSS/Reference/At-rules/@container) CSS at-rule supports [`style()`](/en-US/docs/Web/CSS/Guides/Containment/Container_size_and_style_queries#container_style_queries) queries. This allows you to check if a container has a custom property, optionally with a specific value, and apply styles to its children accordingly. As in other browsers, only [custom properties](/en-US/docs/Web/CSS/Reference/Properties/--*) are supported; queries for regular CSS properties, such as `style(color: green)`, never match. ([Firefox bug 2016929](https://bugzil.la/2016929), ([Firefox bug 2019254](https://bugzil.la/2019254)), ([Firefox bug 2024601](https://bugzil.la/2024601)), [Firefox bug 2030645](https://bugzil.la/2030645)).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, applied in 647c44c.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:CSS Cascading Style Sheets docs Content:Firefox Content in the Mozilla/Firefox subtree size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Info about style() container query is misleading

3 participants