If you're a web developer, you need to be familiar with responsive web design. There are tons of devices out there—phones, tablets, laptops, you name it—all with different screen sizes and abilities. Making sure your site looks good on all of them can be tough. CSS media queries are crucial for creating layouts that adapt to various screen sizes. That’s why they're a big part of Uncodemy's Full Stack Developer course in Noida; they are super important for doing web dev work.


This guide will explain CSS media queries in simple terms, show you how they work, and give you some examples you can actually use. That way, you can build websites that are easy to use and look awesome, no matter what device someone is using.
Media queries in CSS let you change styles based on device stuff. So, you can tweak how your site looks depending on screen size, orientation, resolution, and user settings (like dark mode).
You can do things like:
A media query uses the @media rule to see if certain things are true and then uses specific CSS styles if they are.
Here's what it looks like:
Media type: This is the kind of device, such as all, screen, or print.
Media features: These are the things you want to focus on, like the smallest or largest width, or the orientation.
Logical operators: These let you mix and match conditions (and, not, only)
Here's the basic way to write a media query:
css
@media [media-type] and ([media-feature]) {
/* CSS rules go here */
}
So, you could set a background color, but only if the screen is at least 600 pixels wide.
At Uncodemy's Full Stack Developer course in Noida, creating websites that look good on any device isn't just a skill; it's key to getting hired. Today's employers want developers who can:
Knowing media queries helps you go from making basic web pages to creating smooth, professional websites.
Switch overall styles for mobile versus desktop:
text
@media only screen and (max-width: 600px) {
/* Adjust styles for small screens */
}
Example Use Cases
Most modern designs respond to several common device widths:
| Device | Min/Max Width Rule | What Changes? |
|---|---|---|
| Large desktop | min-width: 1200px | Wide layouts, more columns |
| Tablet | 768px – 1024px | Reduced columns, larger text |
| Phone | max-width: 767px | Single column, menu collapses |
By combining multiple queries:
text
@media (min-width: 768px) and (max-width: 1024px) {
/* Tablet-specific styles */
}
Adapt layout to device orientation:
text
@media (orientation: landscape) {
/* Styles for landscape screens */
}
Switch images or font sizes for legibility:
Cater to system-level settings:
text
@media (prefers-color-scheme: dark) {
/* Dark mode styling */
}
Combine several criteria with logical operators:
text
@media screen and (min-width: 768px) and (orientation: landscape) {
/* Tablet in landscape mode */
}
Basically, media queries are super important for making websites that look and work great on any device, like phones, tablets, and computers, since they let the website change how it looks depending on the screen size.
Why they're great:
Start with mobile: Make your basic styles for phones first, then add changes for bigger screens.
Set smart breakpoints: Don't aim for specific devices; use widths where your layout needs changing.
Keep queries tidy: Group related queries by layout, part, or feature.
Don't use too many breakpoints: Stick to how the content flows naturally, not every device type.
Test a lot: Always check your site on real devices and emulators.
With Uncodemy's Full Stack Developer course in Noida, you’ll learn how to use media queries by actually using them to build things like:
You'll also get good at finding responsive bugs and thinking about breakpoints and user needs.
| Breakpoint | Typical Device | Example Use |
|---|---|---|
max-width: 480px | Mobile portrait | Simplify nav, scale text/buttons up |
max-width: 768px | Tablet portrait | Adjust grids, touch targets, collapse menus |
min-width: 1024px | Desktop/laptop | Multi-column layouts, larger content areas |
orientation: landscape | Tablets/phones wide | Reorder menus, display more info horizontally |
prefers-color-scheme | User preference | Switch to dark or light-themed colors |
Media queries are mostly used to change how websites look on different devices. But they're becoming more useful for making websites that everyone can use easily. With modern CSS, developers can change designs not just for screen size, but also for people's accessibility needs and personal settings. Knowing how to use these media queries is a key skill for developers today. That's why Uncodemy's Full Stack Developer course in Noida teaches it.
Some people don't like or get bothered by things that move on the screen, like animations. To make browsing easier and safer, browsers have a setting called prefers-reduced-motion. If developers see that this setting is on, they can turn off or simplify animations for those users.
How it actually works:
More and more, devices and browsers let people ask for themes with high contrast, or switch between dark and light modes. The prefers-color-scheme and forced-colors media queries let developers:
If you use media queries to change the size of fonts, you can be sure that the main text and headings are easy to read. This is especially useful for people who like bigger fonts or have set a font size in their system. This means:
CSS media queries have totally changed how we make and see websites. They're super important for making websites responsive and work for everyone, now and later. If you take Uncodemy’s Full Stack Developer course in Noida, you will learn media queries, so you can build websites that look great on any device.
Knowing how to use media queries means you'll be ready to handle any challenge and build sites that people will like.
Q1: Why only design for desktops? That seems kinda silly.
These days, most folks browse on phones. If your site's only for desktops, it'll be slow and clunky on phones. Plus, search engines won't like it. Media queries sort this out easily.
Q2: Do media queries slow stuff down?
Nope. If you do them right, your site loads the important bits first, then adjusts how it looks. Browsers only use the CSS they need.
Q3: Is managing tons of media queries a pain?
Not if you're planning. Keep your CSS in order, plan breakpoints based on your layout (not specific phones), and add comments to your queries, so it remains understandable.
Q4: Do media queries matter to backend folks?
Yep! Full stack devs should know both front and backend. They often have to fix problems or speed up how the site feels to people.
Q5: Does Uncodemy’s Full Stack Developer course in Noida teach media queries?
You'll learn media queries in the HTML and CSS parts. You'll also use them in group projects and get feedback on your code. This gives you experience for your portfolio and work.
Personalized learning paths with interactive materials and progress tracking for optimal learning experience.
Explore LMSCreate professional, ATS-optimized resumes tailored for tech roles with intelligent suggestions.
Build ResumeDetailed analysis of how your resume performs in Applicant Tracking Systems with actionable insights.
Check ResumeAI analyzes your code for efficiency, best practices, and bugs with instant feedback.
Try Code ReviewPractice coding in 20+ languages with our cloud-based compiler that works on any device.
Start Coding
TRENDING
BESTSELLER
BESTSELLER
TRENDING
HOT
BESTSELLER
HOT
BESTSELLER
BESTSELLER
HOT
POPULAR