@custom-media

Experimental

An experimental at-rule that lets you define reusable media queries (like '@custom-media --tablet (max-width: 768px)') for cleaner, more maintainable code.

Quick example

/* Experimental: Define a reusable media query */
@custom-media --small-viewport (max-width: 480px);

@media (--small-viewport) {
  .container { padding: 10px; }
}

@custom-media Browser Support

Limited availability Unknown global usage

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Not ready for production without a fallback.

148+
ESC