What if your website could magically change its look to fit any screen perfectly?
Why Media queries in CSS? - Purpose & Use Cases
Imagine you create a website that looks great on your big desktop screen. Then you try to view it on a phone, but the text is tiny and buttons are too close together.
If you try to fix this by making separate versions of your site for each device and switching them manually, it becomes confusing and takes a lot of time. You might forget to update one version or make mistakes.
Media queries let your website automatically adjust its style based on the screen size or device type. This means one site can look good everywhere without extra copies.
/* Desktop styles only */
body { font-size: 16px; }
/* No changes for small screens, looks bad */@media (max-width: 600px) { body { font-size: 14px; } }
Media queries enable your website to respond and look great on any device, from phones to large monitors.
Think of a news website that shows a full menu on desktop but switches to a simple hamburger menu on phones for easy navigation.
Manual styling for each device is slow and error-prone.
Media queries let styles change automatically based on screen size.
This makes websites flexible and user-friendly everywhere.