In the early era of web design, developers created separate desktop sites and mobile subdomains (e.g., m.website.com). In 2010, Ethan Marcotte published his seminal article coining the term Responsive Web Design (RWD). Instead of building multiple duplicate codebases, RWD enables a single HTML document to fluidly adapt its layout, typography, and interactive elements to any screen size.
1. Fluid Grids: Using proportional units (%, fr, rem, vw) instead of rigid fixed-pixel values.
2. Flexible Media: Ensuring images and video never overflow their containers (max-width: 100%).
3. Media & Container Queries: Applying tailored CSS rules based on device capabilities and container widths.
Without the viewport meta tag, mobile browsers assume they are loading a 1990s desktop site. They render the page on a hidden 980px canvas and zoom out, rendering text microscopic and unreadable:
<!-- Place inside <head> of EVERY HTML document -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
In a Mobile-First workflow, you write base CSS without any media queries targeted at mobile screens. You then use min-width media queries to progressively enhance the layout as screen real estate expands:
/* 1. Base Mobile Styles (Default: Single Column) */
.card-container {
display: flex;
flex-direction: column;
gap: 16px;
}
/* 2. Tablet Enhancement (>= 768px: 2 Columns) */
@media (min-width: 768px) {
.card-container {
flex-direction: row;
flex-wrap: wrap;
}
}
/* 3. Desktop Enhancement (>= 1024px: 4 Columns) */
@media (min-width: 1024px) {
.card-container {
display: grid;
grid-template-columns: repeat(4, 1fr);
}
}
Boost your CSS and front-end development proficiency by exploring these closely connected topics:
Understand margins, borders, padding, content and the universal box-sizing fix.
Master 1D alignment, justify-content, align-items, flex-wrap and responsive flow.
Build powerful two-dimensional grid layouts with template areas and fr units.
Eliminate styling conflicts and master selector weights from 0,0,0,1 to !important.