Media queries apply conditional CSS based on environment features like viewport size, user preferences, and device capabilities.
Modern query targets
- Width breakpoints (
min-width/max-width). - User preferences (
prefers-reduced-motion,prefers-color-scheme). - Interaction modes (
hover,pointer).
Production checklist
- Use content-driven breakpoints, not device names.
- Pair responsive checks with accessibility preference queries.
- Test at intermediate widths, not only breakpoint edges.
Important interview questions and answers
- Q: Why mobile-first media queries?
A: Baseline for constrained contexts, then progressive enhancements. - Q: Common breakpoint anti-pattern?
A: Device-brand-specific breakpoints that age poorly. - Q: Why include preference queries?
A: Users signal important comfort/accessibility needs.
Practice: Change one property in the playground and observe cascade + layout in DevTools.