Responsive Design Lesson 24 of 33
Responsive Web Design — Images, Typography and Testing
Put it all together — fluid containers, responsive images, fluid font sizes with clamp(), touch-friendly design and how to test your site on many screen sizes.
Responsive web design means building one website that works well on every screen: a ₱3,000 Android phone, an iPad, a school computer, a big TV. You already know the key tools: max-width, Flexbox, Grid and media queries. This lesson collects the habits that make a whole site responsive, plus a few new tricks.
1. Start with the viewport tag
Every responsive page needs this in the <head>:
<meta name="viewport" content="width=device-width, initial-scale=1">
It tells phones: "use your real screen width, don't pretend to be a desktop."
2. Use fluid containers
Instead of fixed widths, combine max-width with automatic margins and some side padding so text never touches the screen edge:
.container {
max-width: 1100px;
margin: 0 auto;
padding: 0 16px;
}
3. Make images flexible
An image wider than the screen will push the page sideways, the most common cause of that annoying side-scroll on phones. One rule prevents it:
img, video {
max-width: 100%;
height: auto;
}
max-width: 100% lets images shrink to fit their container (but never stretch bigger than their real size), and height: auto keeps their proportions.
<style>
.fixed { width: 600px; }
.fluid { max-width: 100%; height: auto; }
img { border: 2px solid #0f5c4d; background: #fdf3dc; display: block; margin-bottom: 8px; }
</style>
<p>Narrow the editor: the first image overflows, the second shrinks.</p>
<img class="fixed" src="/img/jeepney.svg" alt="Fixed width jeepney">
<img class="fluid" src="/img/jeepney.svg" alt="Flexible jeepney" width="600">
Serving smaller images to phones
A phone doesn't need a 2000-pixel photo. HTML's srcset lets the browser choose a smaller file on small screens, which saves your visitors' mobile data:
<img src="photo-800.jpg"
srcset="photo-400.jpg 400w, photo-800.jpg 800w, photo-1600.jpg 1600w"
sizes="(min-width: 900px) 50vw, 100vw"
alt="Students during the science fair">
The w numbers tell the browser how wide each file is. The sizes attribute says how wide the image will appear: half the screen on big screens, full width on phones. The browser does the math and downloads the best file.
4. Fluid typography with clamp()
A heading that looks great at 48px on a laptop is far too big on a phone. Instead of writing media queries for every heading, clamp() gives a size that grows smoothly with the screen, between a minimum and a maximum:
h1 {
font-size: clamp(1.75rem, 5vw, 3rem);
/* min ideal max */
}
<style>
h1 { font-family: Arial, sans-serif; font-size: clamp(1.5rem, 6vw, 3.25rem); color: #0f5c4d; margin: 0; }
p { font-family: Arial, sans-serif; }
</style>
<h1>Barangay Clean-Up Drive</h1>
<p>Resize the editor: the heading shrinks and grows, but never below 1.5rem or above 3.25rem.</p>
clamp() works for spacing too: padding: clamp(16px, 4vw, 48px);.
5. Readable line length
On very wide screens, a paragraph that stretches across the whole width is tiring to read. Limit text width to about 60–75 characters:
.article p { max-width: 70ch; }
6. Design for fingers
- Make buttons and links at least about 44 × 44 pixels to tap.
- Leave space between tappable things so people don't hit the wrong one.
- Don't hide important information behind hover. Touch screens have no hover, so a menu that only opens on hover won't work on phones.
- Use font sizes of at least 16px in form inputs. On iPhones, smaller inputs make the page zoom in when you tap them.
7. Avoid fixed heights and widths
Most responsive bugs come from fixed sizes. Text wraps onto more lines on a narrow screen, so a height: 200px box overflows. Prefer:
max-widthinstead ofwidthmin-heightinstead ofheight%,fr,remandclamp()instead of big pixel values
8. Test on real screen sizes
You don't need ten phones to test. On a computer:
- Open your page in Chrome or Edge and press F12.
- Click the device toolbar icon (a phone and tablet), or press Ctrl + Shift + M.
- Choose a device from the list, or drag the edge to try every width from 320px up.
Then check on at least one real phone. Look for: sideways scrolling, text that's too small, buttons too close together, and images that are cut off.
A complete responsive section
<style>
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, sans-serif; color: #1d2321; }
.container { max-width: 960px; margin: 0 auto; padding: clamp(16px, 4vw, 40px); }
h1 { font-size: clamp(1.6rem, 5vw, 2.6rem); margin: 0 0 8px; color: #0f5c4d; }
.lead { max-width: 60ch; color: #5b6662; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 16px; }
.card { border: 1px solid #e3e0d6; border-radius: 12px; overflow: hidden; }
.card img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; display: block; background: #fdf3dc; }
.card p { margin: 10px 12px 14px; }
.btn { display: inline-block; margin-top: 16px; padding: 12px 20px; background: #0f5c4d; color: white; text-decoration: none; border-radius: 10px; }
</style>
<div class="container">
<h1>Explore Philippine Food</h1>
<p class="lead">From the sour broth of sinigang to the sweet layers of halo-halo, every region has a dish worth trying. Here are a few favorites.</p>
<div class="grid">
<div class="card"><img src="/img/halo-halo.svg" alt="Halo-halo"><p><strong>Halo-halo</strong> — shaved ice, beans, fruits and leche flan.</p></div>
<div class="card"><img src="/img/mango.svg" alt="Mango"><p><strong>Guimaras mango</strong> — famous for its sweetness.</p></div>
<div class="card"><img src="/img/jeepney.svg" alt="Jeepney"><p><strong>Street food tour</strong> — ride a jeepney to the best stalls.</p></div>
</div>
<a class="btn" href="#">See all recipes</a>
</div>
Quick Quiz
Check what you learned. Walang grade ito, practice lang. 🙂
By Sir Reyel · Last updated 2026-12-04