Mobile-First vs Desktop-First Design
- CSS Basics
- Selectors & Specificity
- Box Model & Units
- Typography & Text Styling
- Colors & Color Spaces
- Positioning & Stacking Context
- Flexbox
- Grid
- Grid Advanced
- Responsive Design
- Container Queries
- Pseudo-classes & Pseudo-elements
- Modern Selectors
- CSS Custom Properties
- CSS Functions
- Transitions & Animations
- Transforms
- Forms & Input Styling
- CSS Architecture & Methodologies
- Accessibility in CSS
- Performance & Optimization
- View Transitions & Modern APIs
- Cascade Layers & Scope
The Desktop-First Approach
Desktop-first starts by writing styles for large screens as the default, then uses max-width media queries to override and simplify the layout for smaller screens.
.layout {
display: grid;
grid-template-columns: 250px 1fr; /* desktop default */
}
@media (max-width: 768px) {
.layout {
grid-template-columns: 1fr; /* simplified for mobile */
}
}The Mobile-First Approach
Mobile-first flips this: the default (unwrapped) styles target the smallest screen, and min-width media queries progressively add complexity as the viewport grows.
.layout {
display: grid;
grid-template-columns: 1fr; /* mobile default */
}
@media (min-width: 768px) {
.layout {
grid-template-columns: 250px 1fr; /* enhanced for larger screens */
}
}Why Mobile-First Is Generally Recommended
- It forces a focus on core content and functionality first, since there is no room to hide complexity on a small screen.
- Base styles stay simpler, and additional complexity is only loaded/applied for larger screens that can handle it.
- It matches how a large share of real-world traffic actually arrives - many sites see more mobile visits than desktop.
Side-by-Side Comparison
| Desktop-first | Mobile-first | |
|---|---|---|
| Default styles target | Large screens | Small screens |
| Media query direction | max-width (shrinking down) | min-width (growing up) |
| Common today? | Less common now | Industry standard approach |