CSS · Layout and visual systems
What does mobile-first mean in CSS?
Short answer
Mobile-first means writing the base styles for the smallest layout, then enhancing with min-width media queries as more space becomes available. It is progressive enhancement rather than desktop downscaling.
The base stylesheet targets the constrained case. Larger screens add columns, spacing and richer layout. This keeps the default CSS small and makes the narrow layout the starting point rather than an afterthought.
.cards {
display: grid;
gap: 1rem;
}
@media (min-width: 48rem) {
.cards {
grid-template-columns: repeat(2, 1fr);
}
}
@media (min-width: 64rem) {
.cards {
grid-template-columns: repeat(3, 1fr);
}
}Why it helps
- The smallest layout is the default, so it cannot be forgotten
- Enhancements are additive and easier to reason about
- Older mobile devices get less CSS and fewer large assets
- It pairs naturally with progressive enhancement and content-first design
Desktop-first with max-width queries is still valid, especially when maintaining an existing desktop product. The important part is that both layouts are intentionally designed, not that one methodology is mandatory.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1What is the difference between mobile-first and desktop-first?
- 2Why use min-width instead of max-width queries?
- 3Does mobile-first mean ignoring desktop users?
- 4How does mobile-first affect performance?
Say it in the interview
Mobile-first means the base CSS is the small-screen layout, and I add enhancements with min-width queries as space increases. That keeps the constrained case as the starting point and avoids stripping down a desktop layout. It also tends to send less CSS and fewer large assets to smaller devices. Desktop-first is still valid, but the layouts should both be intentional.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live CSS mock interview and get scored feedback on depth, clarity and confidence.