If your page looked perfect on a laptop but broke on a phone, you’ve met the reason responsive web design exists. People browse on all devices—small phones, large phones, tablets, laptops, widescreens, even split screens. A modern site must adapt naturally without broken spacing, sideways scrolling, or tiny text.
In this tutorial, we’ll use a mobile-first system: start with the smallest screen (~320px) to prioritize essential content, then scale up to tablets and desktops.
Core building blocks include:
-
Semantic HTML for clean, maintainable structure
-
Viewport meta tag for proper mobile scaling
-
Fluid layouts with %, rem, and viewport units
-
Flexbox for one-dimensional layouts
-
CSS Grid for two-dimensional structures
-
Smart breakpoints with media queries
-
Responsive images & fluid typography with clamp()
-
Touch-friendly UI adjustments
-
Testing with DevTools for performance
By following these steps, you’ll create layouts that look intentional and work seamlessly on every screen.
Step-by-Step: Build a Mobile-First Responsive Layout (From 320px Up)
Step 1 — Mobile-First Strategy (Design for 320px first)
The biggest mindset shift in modern responsive design is simple: start small. Designing for a 320px width forces clarity. You can’t rely on extra space to hide messy decisions. You have to prioritize what matters most—your headline, key actions, and the main content users came for.

Mobile-first helps because:
-
It keeps your layout focused. You design the core experience first.
-
It creates a lightweight foundation. Cleaner CSS, fewer layout hacks.
-
It scales up smoothly. Adding columns and spacing is easier than removing clutter.
Before you touch CSS, take 2 minutes to decide:
-
What must be visible immediately on mobile?
-
What can move lower on the page without hurting the experience?
-
What can be hidden behind a tap (like extra nav links in a menu)?
This quick planning step prevents the most common responsive layout problems later.
Step 2 — Core HTML Setup (Semantic structure + viewport)
A modern responsive layout starts with clean, semantic HTML. Use HTML5 tags like <header>, <main>, and <footer> so your structure is clear (and easier to style, maintain, and understand).
Here’s a simple starting structure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Responsive Layout Tutorial</title>
</head>
<body>
<header class="site-header">
<div class="container">
<a class="logo" href="#">Brand</a>
<nav class="site-nav">
<a href="#">Home</a>
<a href="#">Services</a>
<a href="#">Blog</a>
<a href="#">Contact</a>
</nav>
<a class="cta" href="#">Get Started</a>
</div>
</header>
<main class="site-main">
<section class="hero container">
<h1>Modern Responsive Web Layout</h1>
<p>Build layouts that look great on mobile, tablet, and desktop.</p>
</section>
</main>
<footer class="site-footer">
<div class="container">© 2026 Brand</div>
</footer>
</body>
</html>
The viewport meta tag is non-negotiable:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Without it, mobile browsers may render your site on a “fake” wider canvas and shrink everything down—making text tiny and the layout feel broken.
Step 3 — Fluid Layout Rules (No fixed pixels)
A responsive layout breaks when it depends on fixed widths like 1200px. Instead, use fluid units:
-
% for flexible container widths
-
rem for consistent spacing and typography
-
vw/vh for viewport sizing (use carefully)
-
max-width to prevent overly wide layouts
A simple container pattern works in almost every project:
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, Arial, sans-serif; line-height: 1.5; }
.container {
width: min(1100px, 100% - 2rem);
margin-inline: auto;
}
Now your layout adapts on small screens and stays readable on large screens.
Also, know the difference between Flexbox and Grid:
-
Flexbox: best for one-dimensional layout (rows or columns)—navbars, button groups, centering.
-
CSS Grid: best for two-dimensional layout (rows and columns)—full page structure and card grids.
Modern Layout Patterns Using Flexbox + CSS Grid
Pattern 1 — A Modern Header (logo + nav + CTA)
A modern header usually has three parts: a logo, navigation links, and a call-to-action button. Mobile-first means the nav can be hidden initially, then enabled later with breakpoints.

.site-header {
position: sticky;
top: 0;
background: white;
border-bottom: 1px solid #eee;
z-index: 10;
}
.site-nav { display: none; } /* mobile-first */
.cta {
text-decoration: none;
background: #111;
color: #fff;
padding: 0.75rem 1rem;
border-radius: 999px;
font-weight: 600;
}
This gives you a clean header on mobile. On tablet/desktop, you’ll show the full nav.
Pattern 2 — Responsive Hero + Content Section
A hero section usually stacks on mobile (headline → text → buttons). On larger screens, it can become a two-column layout. Here’s the mobile base styling:
.hero { padding-block: 3rem; }
.hero h1 { margin: 0 0 0.75rem; font-size: 2rem; letter-spacing: -0.02em; }
.hero p { margin: 0; color: #444; max-width: 60ch; }
Later, you’ll upgrade it into a two-column layout using Grid—text on the left, visual on the right.
Pattern 3 — Responsive Card Grid (portfolio/blog/eCommerce)
Card grids are everywhere: blog lists, product grids, portfolios. Start mobile-first with one column:
.card-grid {
display: grid;
grid-template-columns: 1fr;
gap: 1rem;
}
.card {
border: 1px solid #eee;
border-radius: 18px;
padding: 1.25rem;
background: white;
box-shadow: 0 8px 20px rgba(0,0,0,0.04);
}
Then use breakpoints—or a modern auto-fit trick—to scale up.
Breakpoints That Make Sense (And Don’t Break Your Design)
Step 4 — Smart Breakpoints with Media Queries
Breakpoints shouldn’t feel random. Use them when the layout starts to feel tight. Still, these are common modern baseline breakpoints:
Mobile-first media query structure:
@media (min-width: 768px) { /* tablet upgrades */ }
@media (min-width: 1024px) { /* desktop upgrades */ }
@media (min-width: 1366px) { /* large screens */ }
Enable navigation on tablet: