@custom-media

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

This is an experimental technology. The syntax and behavior are still subject to change.

/* Usage Example */
/* Experimental: Define a reusable media query */
@custom-media --small-viewport (max-width: 480px);
@media (--small-viewport){
.container{ padding: 10px; }
}
Limited availability Since 2020 Unknown global usage

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

148+
Kinsta

Your first month is free

Managed WordPress hosting for faster sites.

Learn more

New CSS drops.

Join 600+ readers who've survived clearfix hacks.

ESC