← Back to release summary

@custom-media

Category
CSS
Type
New or changed feature
Status
Proposed (Chrome Proposed)
Intent stage
None

Summary

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 */ }

Motivation

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/.

Standards & signals

Ecosystem

View on chromestatus.com