CSS · At-rules, values and responsive design

@media query

Applies rules when a media condition matches: width, pointer type, colour scheme or reduced motion.

Syntax
@media (min-width: 40rem) { … }

Example

Try it

Notes

Write mobile-first rules with min-width so the base styles serve small screens.

More in this group

@container @font-face @import @layer @supports calc() clamp() Color functions

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course