Element's matchContainer()
- Category
- CSS
- Type
- New or changed feature
- Status
- Proposed (Chrome Proposed)
- Intent stage
- None
Summary
Introduce matchContainer() on Element instances for the container query, that provides a similar mechanism to window.matchMedia().
Motivation
CSS Media Queries have a method window.matchMedia(), which gives a script the ability to listen for media query changes. Web Devs proposed that CSS Container Queries have the same functionality. And then, CSSWG resolved this proposal as "RESOLVED: Add a matchContainer method as proposed in issue. Keep issue open to decide if need new observer or if we can reuse the existing".
Standards & signals
- Specification: https://github.com/w3c/csswg-drafts/pull/13551
- Firefox: No signal
- Safari: No signal
- Web developers: No signals
- Tracking bug: https://issues.chromium.org/issues/40887402
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=element-s-matchcontainer
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+Element's%20matchContainer()
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=Element's%20matchContainer()
- Baseline status: https://webstatus.dev/?q=Element's%20matchContainer()
Explainers: https://github.com/w3c/csswg-drafts/issues/6205