CSS Media Queries
CSS
What are CSS Media Queries?
Media Queries let you apply different styles depending on the device’s:
- Width / height
 - Screen size
 - Orientation
 - Resolution This is how you make a website mobile-friendly or responsive.
 
This will apply a blue background only when the screen width is 600px or smaller (mobile/tablet).
| Feature | Example | Meaning | 
|---|---|---|
| max-width | (max-width: 768px) | Up to 768px (phones/tablets) | 
| min-width | (min-width: 1024px) | From 1024px and up (desktops) | 
| orientation | (orientation: landscape) | Wide view (sideways) | 
| resolution | (min-resolution: 2dppx) | High-density displays (retina) | 
Media Types
| Type | Description | 
|---|---|
| all | Default, applies to all | 
| screen | Computer, phone, tablets | 
| Print preview & paper | |
| speech | Screen readers | 
Multiple Conditions
Example
| Concept | Use Case | 
|---|---|
| @media | Define conditional CSS | 
| max-width | Apply styles below a width | 
| min-width | Apply styles above a width | 
| Responsive UI | Adapts to phone, tablet, desktop screens |