Building Responsive Layouts (Mobile + Tablet)
Learn how to design pages that look great and work smoothly on phones and tablets. You’ll plan breakpoints, use fluid sizing, test across viewports, and fix common issues—without breaking your desktop design.
Learning Objectives
- Define mobile-first breakpoints for phone and tablet layouts.
- Use fluid spacing, typography, and media that adapt to screen width.
- Reflow sections using columns/containers and responsive controls.
- Test and debug with browser device simulators and real devices.
- Apply accessibility and performance best practices for touch screens.
Key Terms
- Breakpoint: A screen width at which layout styles change (e.g., 768px for tablets, 480–576px for phones).
- Mobile-First: Design starts at the smallest screen then scales up.
- Fluid Units: Relative units like
em,rem,%,vw, andclamp()for sizing. - Viewport: The visible area of a webpage on a device.
- Touch Target: The tappable area of an interactive element (recommended ≥ 44×44 px).
Before You Start
- Your theme or page builder is installed and you can edit pages.
- You have a basic desktop layout built (hero, features, CTA, footer).
- You can open DevTools in your browser (Chrome/Edge/Firefox).
Responsive Strategy in 5 Steps
- Plan breakpoints: Phone (≤ 480–576px), Tablet (≈ 768–1024px). Keep them simple.
- Set fluid type & spacing: Use relative units and
clamp()for headings, body text, margins/padding. - Reflow layout: Multi-column sections collapse to single column on phones; adjust order if needed.
- Constrain media: Make images/videos scale within their containers and avoid overflow.
- Test & iterate: Simulate devices in DevTools and validate on a real phone/tablet.
Recommended Breakpoints
| Device | Width Range | Primary Actions |
|---|---|---|
| Phone | 320–576px | Single column, larger buttons, stack media under text, reduce spacing. |
| Tablet | 768–1024px | Two columns where useful, adjust typography and gutters, center CTAs. |
Tip: It’s fine to use just two custom breakpoints if your theme/page builder also offers defaults.
Hands-On Workflow (Phone → Tablet → Desktop)
- Switch to Phone view in your editor or narrow your browser to ~375px.
- Collapse columns: For 2–4 column sections, stack them vertically. Ensure a clear reading order (heading → text → media → CTA).
- Adjust spacing: Reduce large paddings/margins; keep consistent vertical rhythm (e.g., 16–24px between blocks).
- Scale text: Ensure headings don’t wrap awkwardly. Use fluid sizes (see snippet below).
- Fix media overflow: Set images/videos to max-width 100% within containers.
- Upgrade to Tablet view: Reintroduce 2-column layouts for features or text+image pairs.
- Check CTAs & forms: Make buttons full width on phones, increase input spacing and label size.
- Navigation: Use a hamburger or off-canvas on phones; simple top bar on tablets.
Optional Copy-Paste Snippets
1) Fluid Typography with clamp()
<!-- Add in a Custom CSS area if your theme allows -->
:root{
--step--1: clamp(0.875rem, 0.83rem + 0.22vw, 1rem); /* small text */
--step-0: clamp(1rem, 0.95rem + 0.30vw, 1.125rem); /* body */
--step-1: clamp(1.25rem, 1.10rem + 0.90vw, 1.5rem); /* h4 */
--step-2: clamp(1.5rem, 1.20rem + 1.6vw, 2rem); /* h3 */
--step-3: clamp(2rem, 1.60rem + 2.5vw, 2.75rem); /* h2 */
--step-4: clamp(2.5rem, 1.80rem + 4vw, 3.5rem); /* h1 */
}
h1{font-size:var(--step-4)} h2{font-size:var(--step-3)} h3{font-size:var(--step-2)}
h4{font-size:var(--step-1)} body, p{font-size:var(--step-0); line-height:1.6}
2) Mobile-First Columns
<section class="features">
<div class="feature">Feature A</div>
<div class="feature">Feature B</div>
</section>
<style>
.features{
display:grid;
grid-template-columns: 1fr; /* phone: 1 column */
gap: 16px;
}
@media (min-width: 768px){ /* tablet: 2 columns */
.features{ grid-template-columns: 1fr 1fr; gap: 24px; }
}
@media (min-width: 1024px){ /* desktop: 3 columns */
.features{ grid-template-columns: 1fr 1fr 1fr; gap: 32px; }
}
</style>
3) Responsive Media
<figure class="media-wrap">
<img src="your-image.jpg" alt="Descriptive alt text">
<figcaption>Optional caption</figcaption>
</figure>
<style>
.media-wrap img{ max-width:100%; height:auto; display:block; }
.media-wrap{ margin: 0 auto; width: min(100%, 720px); }
</style>
4) Touch-Friendly Buttons
<a class="btn-primary" href="#contact">Get Started</a>
<style>
.btn-primary{
display:inline-block;
padding: 14px 20px; /* ~44px tall on most devices */
min-height: 44px;
line-height: 1.2;
text-decoration:none;
border-radius: 8px;
}
@media (max-width: 576px){
.btn-primary{ display:block; width:100%; text-align:center; }
}
</style>
Testing & Debugging
- Browser DevTools: Toggle device toolbar and preview common sizes (375×812, 414×896, 768×1024).
- Real Devices: Load the page on a phone/tablet; scroll and tap every interactive element.
- Scrolling & Overflow: Look for horizontal scroll bars. If present, find and fix any element wider than the viewport.
- Images: Check that images don’t blur or crop oddly; compress large images for faster loads.
- Forms: Ensure inputs are large enough and labels are clear; test the keyboard type on mobile (email, number, etc.).
Accessibility & Performance
- Touch targets: Minimum 44×44 px; give links enough spacing to avoid mis-taps.
- Contrast: Maintain readable color contrast for text on backgrounds.
- Focus states: Keep visible focus rings for keyboard users.
- Motion: Avoid large parallax or heavy video on mobile; provide a static fallback.
- Optimize assets: Use modern image formats and lazy-load below-the-fold media to improve Core Web Vitals.
Common Pitfalls to Avoid
- Using fixed pixel sizes everywhere (causes cramped mobile layouts).
- Forgetting to collapse multi-column sections for phones.
- Buttons and links too small or too close together.
- Hero text too large on small screens (use
clamp()). - Images set with fixed width larger than the container (use
max-width:100%).
Activity: Make Your Home Page Mobile-Ready
- Open your Home page and switch to Phone preview.
- Collapse each multi-column section to 1 column. Reorder blocks for a logical reading flow.
- Apply fluid typography: h1–h4 and body using your theme/page builder controls or the CSS snippet.
- Set images to scale within their containers; ensure no horizontal scroll.
- Convert primary CTA buttons to full-width on phones.
- Switch to Tablet preview and adjust gutters and column counts.
- Test on a real phone and tablet; note any issues and fix them.
Deliverable: A screenshot of your Home page in Phone and Tablet sizes, plus a brief note (3–5 bullets) on what you changed.
Mobile & Tablet Checklist
- No horizontal scrolling at 375px and 768px widths.
- Readable text sizes and line-height at all breakpoints.
- Buttons and links are easy to tap (≥ 44px height).
- Images and videos scale and remain sharp.
- Navigation is usable on phone (hamburger/off-canvas) and tablet (simple top bar).
- Primary CTAs visible without excessive scrolling.
Assessment
Quick Quiz (5 Questions)
- What is a breakpoint and why is it used?
- Name two advantages of mobile-first design.
- What’s the recommended minimum touch-target size?
- How do you prevent images from causing horizontal scroll?
- When would you switch from 1 to 2 columns on tablet?
Practical Task
Take an existing 3-section page (hero, features, CTA) and make it responsive for phone and tablet. Provide device screenshots and a 1-paragraph summary of your changes.
FAQ
Do I need many breakpoints?
No. One phone and one tablet breakpoint cover most layouts. Add more only for specific design needs.
My text is huge on phones—what should I do?
Use relative sizing and clamp() to cap large headings and ensure a readable minimum size.
Images look blurry on mobile—why?
Use appropriately sized and compressed images. Avoid stretching small images into large containers.