The proposed @custom-media at-rule is a feature that would allow developers to define and name their own media queries. This would make responsive design code cleaner and more maintainable by reducing repetition. For example: @custom-media --narrow-window (max-width: 30em); @media (--narrow-window) { /* styles for narrow windows */ }
The primary motivation for introducing the @custom-media feature is to enhance CSS development by making it more efficient, readable, and maintainable. It directly addresses the common issue of developers having to repeatedly write the same media query conditions, allowing them instead to define meaningful, reusable aliases. This feature is a feature highly requested by developers; the Chromium bug report has 233 stars, Chris Coyier and Stefan Judis have shared interest in this feature in their posts: https://www.stefanjudis.com/notes/can-we-have-custom-media-queries-please/, https://css-tricks.com/can-we-have-custom-media-queries-please/.
None
Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?
None
None
No milestones specified