Unit 6 ยท Cascading Style Sheets (CSS)

6.6.1CSS Media Queries

Apply rules only when a condition is true.

CSS
/* Mobile-first: write the small-screen styles normally... */
.container { padding: 10px; }
.menu { display: none; }

/* ...then enhance for larger screens */
@media (min-width: 768px) {
  .container { padding: 30px; }
  .menu { display: flex; }
}

@media (min-width: 1200px) {
  .container { max-width: 1140px; margin: auto; }
}

/* Other conditions */
@media (max-width: 600px) { .sidebar { display: none; } }
@media (orientation: landscape) { /* ... */ }
@media print { nav, footer { display: none; } }
@media (prefers-color-scheme: dark) { body { background: #111; color: #eee; } }

Common breakpoints: about 576px (phones), 768px (tablets), 992px (small laptops), 1200px (desktops). Choose breakpoints where your content starts to look bad rather than by device names.

phones0phones (L)576pxtablets768pxlaptops992pxdesktops1200px +screen width
Breakpoints are widths where the layout changes; mobile-first CSS adds rules with min-width