Responsive Website QA
By the end of this lesson you will be able to run a repeatable responsive QA pass on any website. You will test the widths between breakpoints, check reflow at 320 CSS pixels and zoom at 200%, stress layouts with long Indian names and Hindi text, and use two automated checks: an overflow detector and Playwright screenshot comparison.
What you should know first: Responsive HTML Architecture (how to build it), Accessibility Engineering: WCAG 2.2, Cross-Browser Compatibility and Playwright Browser Testing. Cross-Device Compatibility Testing covers real phones and tablets; this lesson is about the layout itself.
What responsive QA checks
Responsive QA means proving that a page works at every width, zoom level and orientation a visitor might use, with real content in it. A tailor in Jaipur does not check a kurta only on the mannequin; he asks the customer to sit, raise their arms and turn around. A QA pass makes the layout move in five ways:
| Change | What to try | Rule behind it |
|---|---|---|
| Width | 320 px up to 1920 px, including the gaps between breakpoints | WCAG 1.4.10 Reflow |
| Zoom and text size | Browser zoom 200% and 400%, phone font size set to large | WCAG 1.4.4 Resize Text |
| Content | Long names, Hindi text, long emails and URLs, big rupee amounts | Real data is never the demo data |
| Input | Fingers instead of a mouse, keyboard Tab order at each width | WCAG 2.5.8 Target Size, 2.4.11 Focus Not Obscured |
| Orientation | Phone in landscape, where the screen is only about 360 px tall | WCAG 1.3.4 Orientation |
Breakpoints and the ranges between them
A breakpoint is a width where the layout changes, usually through a media query or container query. Most teams test exactly at their device presets: 375, 768 and 1280 pixels. Bugs rarely live there, because the designer drew those widths. They live in the ranges between.
A two-column grid that starts at 600 px has 290 px columns at 600 px and 490 px columns at 1000 px. The same card must work across that whole range:
- Step 1: list the breakpoints from your CSS (search for
@mediaand@container). - Step 2: test one pixel below and at each one, for example 599 and 600 for
min-width: 600px. - Step 3: in DevTools device mode, drag slowly from 320 to 1920 px, watching for overlaps, cut-off text and a horizontal scrollbar.
- Step 4: note every width where something breaks; these become fixed widths for automation.
Reflow at 320 CSS pixels and zoom at 200%
WCAG 1.4.10 (Reflow, level AA) says content must work at a width of 320 CSS pixels without scrolling in two directions. A CSS pixel is the unit your CSS uses, not a hardware dot. Browser zoom changes how many CSS pixels fit: a 1280 px laptop window at 400% zoom is exactly 320 CSS pixels wide. So the 320 px test also covers a low-vision user zooming a desktop page.
Data tables, maps and diagrams may scroll sideways; the rest of the page may not. WCAG 1.4.4 (Resize Text) separately asks that text can grow to 200% without losing content. So zoom a 1280 px window to 400% and check that only tables scroll sideways, then zoom to 200% and look for text clipped inside fixed-height boxes, such as buttons with height: 40px.
Step 1: an overflow detector
Finding the element that causes sideways scrolling by eye is slow. The detector below loads a test page into a frame at the width you choose, then lists every outermost element whose right edge goes past the viewport. Elements inside a container that scrolls on purpose, such as a table wrapper with overflow-x: auto, are skipped.
<!DOCTYPE html>
<html lang="en-IN">
<head>
<meta charset="utf-8">
<title>Overflow detector</title>
<style>
body { font-family: system-ui, sans-serif; margin: 16px; }
iframe { display: block; height: 380px; border: 2px solid #455a64; margin-block: 8px; }
li { margin: 4px 0; }
</style>
</head>
<body>
<h1>Overflow detector</h1>
<p>
<label>Width <select id="width"><option>320</option><option>375</option><option>768</option></select></label>
<label><input type="checkbox" id="fixed"> Apply the fixes</label>
</p>
<iframe id="frame" title="Page under test"></iframe>
<ul id="report"></ul>
<script>
const page = `<!DOCTYPE html><html lang="en-IN"><head><meta charset="utf-8">
<style>
body { font-family: system-ui, sans-serif; margin: 0; padding: 12px; }
.banner { width: 600px; height: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.card { display: flex; gap: 8px; border: 1px solid #ccc; padding: 8px; }
table { border-collapse: collapse; } th, td { border: 1px solid #ccc; padding: 4px; }
FIXES
</style></head><body>
<img class="banner" src="https://course.ethicscomputer.in/assets/samples/landscape.svg" alt="Diwali sale banner" width="600" height="375">
<div class="grid">
<div class="card"><img src="https://course.ethicscomputer.in/assets/samples/avatar.svg" alt="" width="40" height="40"><div><h2>Priya Sharma</h2></div></div>
<div class="card"><img src="https://course.ethicscomputer.in/assets/samples/avatar.svg" alt="" width="40" height="40"><div><h2>Venkatanarasimharajuvaripeta Stores</h2></div></div>
</div>
<div class="wrap"><table>
<tr><th>Order</th><th>Customer</th><th>Item</th><th>Pincode</th><th>Amount</th></tr>
<tr><td>MH-1042</td><td>Ananya Krishnamurthy</td><td>Bandhej saree</td><td>302003</td><td>₹2,499</td></tr>
</table></div>
</body></html>`;
const fixes = `img { max-width: 100%; height: auto; }
.card > div { min-width: 0; }
h2 { overflow-wrap: anywhere; }
.wrap { overflow-x: auto; }`;
// The detector: outermost elements that stick out past the viewport
function findWideElements(doc) {
const limit = doc.documentElement.clientWidth;
const tooWide = (el) => el.getBoundingClientRect().right > limit + 1;
const insideScroller = (el) => {
for (let p = el.parentElement; p && p !== doc.body; p = p.parentElement) {
if (doc.defaultView.getComputedStyle(p).overflowX !== "visible") return true;
}
return false;
};
return [...doc.body.querySelectorAll("*")]
.filter((el) => tooWide(el) && !tooWide(el.parentElement) && !insideScroller(el));
}
const frame = document.querySelector("#frame");
function load() {
frame.style.width = document.querySelector("#width").value + "px";
frame.srcdoc = page.replace("FIXES", document.querySelector("#fixed").checked ? fixes : "");
}
frame.addEventListener("load", () => {
const doc = frame.contentDocument;
const root = doc.documentElement;
// Phones have overlay scrollbars, so add the desktop scrollbar width back
frame.style.width = (frame.clientWidth + frame.clientWidth - root.clientWidth) + "px";
requestAnimationFrame(() => report(doc));
});
function report(doc) {
const root = doc.documentElement;
const lines = [`Viewport ${root.clientWidth}px, page scrolls sideways by ${root.scrollWidth - root.clientWidth}px`];
for (const el of findWideElements(doc)) {
el.style.outline = "3px solid red";
const label = (el.innerText || el.className).replace(/\s+/g, " ").slice(0, 28);
lines.push(`<${el.tagName.toLowerCase()}> "${label}" ends at ${Math.round(el.getBoundingClientRect().right)}px`);
}
document.querySelector("#report").replaceChildren(...lines.map((text) => {
const li = document.createElement("li");
li.textContent = text;
return li;
}));
}
document.querySelector("#width").addEventListener("change", load);
document.querySelector("#fixed").addEventListener("change", load);
load();
</script>
</body>
</html>At 320 px the report names three culprits: the 600 px banner, the long store name and the table. At 768 px only the long name is left: the grid now has two columns and the name no longer fits one. Tick "Apply the fixes" and the list is empty. You can also paste findWideElements into the DevTools Console on your own pages and call findWideElements(document).
Step 2: stress the layout with real Indian content
Real data in India includes long South Indian names, long shop names, Hindi text, long email addresses and amounts such as ₹1,00,00,000. Venkatanarasimharajuvaripeta, a railway station in Andhra Pradesh, makes a perfect test word. This tool puts each test string into the same contact card inside a 300 px box and measures any overflow.
<!DOCTYPE html>
<html lang="en-IN">
<head>
<meta charset="utf-8">
<title>Content stress test</title>
<style>
body { font-family: system-ui, sans-serif; margin: 16px; }
.phone { inline-size: 300px; border: 2px solid #455a64; padding: 8px; }
.card + .card { margin-block-start: 8px; }
.card { display: flex; gap: 8px; align-items: center; border: 1px solid #ccc; padding: 8px; }
.card p { margin: 0; font-weight: 600; }
.card button { min-block-size: 32px; }
.fixed .info { min-width: 0; flex: 1; }
.fixed .card p { overflow-wrap: anywhere; }
.over { color: #b00020; }
</style>
</head>
<body>
<h1>Content stress test</h1>
<p><label><input type="checkbox" id="fix"> Apply the fixes</label></p>
<div class="phone" id="phone"></div>
<ul id="report"></ul>
<script>
const samples = [
["Short name", "Priya Sharma", "en"],
["Long place name", "Venkatanarasimharajuvaripeta Handlooms", "en"],
["Hindi", "श्रीमती अन्नपूर्णा कृष्णमूर्ति, विशाखापत्तनम", "hi"],
["Email", "ananya.krishnamurthy.orders@example.co.in", "en"],
["Amount", "Due: ₹1,00,00,000", "en"],
["URL", "example.co.in/sarees/bandhej/red-cotton-5-5m", "en"]
];
const phone = document.querySelector("#phone");
for (const [, text, lang] of samples) {
phone.insertAdjacentHTML("beforeend",
`<div class="card"><img src="https://course.ethicscomputer.in/assets/samples/avatar.svg" alt="" width="40" height="40">
<div class="info"><p lang="${lang}"></p></div><button type="button">Call</button></div>`);
phone.lastElementChild.querySelector("p").textContent = text;
}
function measure() {
phone.classList.toggle("fixed", document.querySelector("#fix").checked);
const cards = phone.querySelectorAll(".card");
document.querySelector("#report").replaceChildren(...samples.map(([label], i) => {
const extra = cards[i].scrollWidth - cards[i].clientWidth;
const li = document.createElement("li");
li.textContent = extra > 0 ? `${label}: overflows by ${extra}px` : `${label}: fits`;
li.className = extra > 0 ? "over" : "";
return li;
}));
}
document.querySelector("#fix").addEventListener("change", measure);
measure();
</script>
</body>
</html>Without fixes, the place name, the email and the URL push the Call button out of the card. Flex and grid items default to min-width: auto, so they refuse to shrink below their longest word. min-width: 0 lets them shrink, and overflow-wrap: anywhere breaks a word that is still too long. The Hindi line wraps at its spaces, but test it with your real fonts: Devanagari vowel signs sit above and below the line, so a fixed height with a tight line-height can clip them.
Images, tables and tap targets on small screens
- Images: each one scales down (
max-width: 100%), keeps its shape, and the phone crop from<picture>still shows the subject. In the Network panel, confirm a small file fromsrcsetloads at 360 px. - Tables: a wide table may scroll inside a wrapper. Give the wrapper
tabindex="0",role="region"and anaria-labelso keyboard users can scroll it too; see Accessible Tables & Data Presentation. - Tap targets: WCAG 2.5.8 asks for at least 24 by 24 CSS pixels, or space around smaller targets. Lighthouse & HTML Auditing measures them; on a real phone, try dialog close icons, cart quantity buttons and stacked footer links with your thumb.
Orientation and sticky elements
A landscape phone viewport is only about 360 px tall. A sticky header, a cookie bar and a chat button can leave less than half of it for content. WCAG 1.3.4 says you must not lock a page to one orientation unless that is essential, such as a cheque-scanning screen. In landscape, check that:
- Step 1: a full paragraph is readable between the sticky header and footer;
- Step 2: a modal dialog scrolls when it is taller than the screen;
- Step 3: no focused link hides completely under a sticky bar while you press Tab (WCAG 2.4.11). The
scroll-paddingfix is in Accessibility Engineering: WCAG 2.2.
Step 3: automate it with Playwright
Manual checks find problems; automated checks stop them coming back. This Playwright test (version 1.65, against the shop page on a local PHP server) runs the overflow detector at four widths and compares a full-page screenshot with an approved copy.
// tests/responsive.spec.mjs
import { test, expect } from "@playwright/test";
const widths = [320, 375, 768, 1280];
function findWideElements() {
const limit = document.documentElement.clientWidth;
const tooWide = (el) => el.getBoundingClientRect().right > limit + 1;
const insideScroller = (el) => {
for (let p = el.parentElement; p && p !== document.body; p = p.parentElement) {
if (getComputedStyle(p).overflowX !== "visible") return true;
}
return false;
};
return [...document.body.querySelectorAll("*")]
.filter((el) => tooWide(el) && !tooWide(el.parentElement) && !insideScroller(el))
.map((el) => `<${el.tagName.toLowerCase()}> "${(el.className || el.innerText).replace(/\s+/g, " ").slice(0, 24)}"` +
` ends at ${Math.round(el.getBoundingClientRect().right)}px`);
}
for (const width of widths) {
test.describe(`${width}px`, () => {
test.beforeEach(async ({ page }) => {
await page.setViewportSize({ width, height: 800 });
await page.goto("/cards");
});
test("no element wider than the viewport", async ({ page }) => {
expect(await page.evaluate(findWideElements)).toEqual([]);
});
test("matches the approved screenshot", async ({ page }) => {
await expect(page).toHaveScreenshot(`cards-${width}.png`, { fullPage: true });
});
});
}page.evaluate() runs the function inside the browser and returns its result. toHaveScreenshot() compares the page with a saved baseline image. The config sets baseURL to the local server and channel: "chrome" for the installed Chrome. The overflow tests on the unfixed page gave this (trimmed):
npx playwright test -g "no element"x 1 tests\responsive.spec.mjs:28:5 › 320px › no element wider than the viewport (453ms) x 2 tests\responsive.spec.mjs:28:5 › 375px › no element wider than the viewport (951ms) x 3 tests\responsive.spec.mjs:28:5 › 768px › no element wider than the viewport (871ms) ok 4 tests\responsive.spec.mjs:28:5 › 1280px › no element wider than the viewport (1.1s) + Array [ + "<img> \"banner\" ends at 616px", + "<div> \"Venkatanarasimharajuvari\" ends at 432px", + "<table> \"Order Customer Item Pinc\" ends at 477px", + ] + Array [ + "<div> \"Venkatanarasimharajuvari\" ends at 808px", + ]
The first list is from 320 px and the second from 768 px. After the fixes, npx playwright test --update-snapshots saved four baseline images and all eight tests passed. Then a teammate changed the card grid from minmax(260px, 1fr) to minmax(380px, 1fr):
x 1 tests\responsive.spec.mjs:28:5 › 320px › no element wider than the viewport (1.3s)
x 2 tests\responsive.spec.mjs:32:5 › 320px › matches the approved screenshot (3.1s)
x 3 tests\responsive.spec.mjs:28:5 › 375px › no element wider than the viewport (975ms)
x 4 tests\responsive.spec.mjs:32:5 › 375px › matches the approved screenshot (2.6s)
ok 5 tests\responsive.spec.mjs:28:5 › 768px › no element wider than the viewport (568ms)
x 6 tests\responsive.spec.mjs:32:5 › 768px › matches the approved screenshot (1.8s)
ok 7 tests\responsive.spec.mjs:28:5 › 1280px › no element wider than the viewport (508ms)
ok 8 tests\responsive.spec.mjs:32:5 › 1280px › matches the approved screenshot (741ms)
Expected an image 768px by 800px, received 768px by 830px. 11151 pixels (ratio 0.02 of all image pixels) are different.At 768 px nothing overflowed, so the detector passed, but the grid quietly dropped to one column and the page grew 30 px taller. Only the screenshot caught it, which is why you want both checks.
Common mistakes
- Testing only at device presets. Bugs live between breakpoints; drag through the ranges.
- Testing with short dummy text. Use long names, Hindi text, long emails and big amounts.
- Hiding the problem with
overflow-x: hiddenonbody. The scrollbar goes away, but the content is still cut off. - Accepting every screenshot diff. Running
--update-snapshotswithout looking approves the bug too. - Forgetting landscape and zoom. A page that works at 360 by 800 can fail at 800 by 360.
Interview questions
1. What does WCAG 1.4.10 Reflow require, and how do you test it?
Content must be usable at a width of 320 CSS pixels without scrolling in two directions, except for content such as data tables and maps. Test it by setting the viewport to 320 px, or by zooming a 1280 px window to 400%, which gives the same CSS width.
2. Why should you test between breakpoints and not only at them?
Designs are drawn at a few widths, so those usually work. Between breakpoints, columns are narrower or wider than the designer expected, and long words, images and fixed widths start to overflow. Test both sides of each breakpoint and drag through every range.
3. A long word pushes a flex item out of its container. Why, and how do you fix it?
Flex and grid items default to min-width: auto, which stops them shrinking below their content's minimum width. Set min-width: 0 on the item so it can shrink, and overflow-wrap: anywhere on the text so long words can break.
4. How do you find which element causes horizontal scrolling?
Compare each element's bounding box with document.documentElement.clientWidth and report the outermost ones that extend past it, skipping elements inside intentional scroll containers. DevTools can help by outlining elements, and the same script can run in Playwright at several widths.
5. What is visual regression testing, and what are its limits?
It saves approved screenshots and fails when a new screenshot differs. It catches layout changes that no assertion checks, such as a grid losing a column. It is sensitive to fonts, operating systems and dynamic content, so baselines must come from a consistent environment and every diff needs a human review.
Key points
- Responsive QA tests widths, zoom, content, input and orientation, not just three device presets.
- Test both sides of every breakpoint and drag through the ranges between them.
- 320 CSS pixels covers WCAG 1.4.10 and 400% zoom on a 1280 px screen; check 200% text zoom too.
- Stress layouts with long Indian names, Hindi text, emails, URLs and big rupee amounts; fix with
min-width: 0andoverflow-wrap: anywhere. - Wide tables may scroll inside a focusable, labelled wrapper; check tap targets, landscape and sticky bars.
- Automate with an overflow detector plus screenshot comparison at fixed widths; review every diff.
Exercise
Take a page you built earlier, such as your portfolio or business website. List its breakpoints, then run the overflow detector from the Console at 320 px, one pixel below each breakpoint, and at each breakpoint. Replace one name on the page with "Venkatanarasimharajuvaripeta Handlooms" and one paragraph with Hindi text, and test again. Finally, write a Playwright test file that checks for overflow and compares screenshots at 320, 375, the widths around each breakpoint, and 1280 px. Record each bug you find with its width.
Show solution
A portfolio with breakpoints at 600 and 1024 px gives this width list and test:
// tests/portfolio.spec.mjs
import { test, expect } from "@playwright/test";
const widths = [320, 375, 599, 600, 1023, 1024, 1280];
for (const width of widths) {
test(`portfolio at ${width}px`, async ({ page }) => {
await page.setViewportSize({ width, height: 900 });
await page.goto("/");
const wide = await page.evaluate(() => {
const limit = document.documentElement.clientWidth;
return [...document.body.querySelectorAll("*")]
.filter((el) => el.getBoundingClientRect().right > limit + 1)
.map((el) => el.tagName);
});
expect(wide).toEqual([]);
await expect(page).toHaveScreenshot(`home-${width}.png`, { fullPage: true });
});
}A typical bug log: "599 px: project titles overflow cards (fixed with min-width: 0)"; "320 px: contact email pushes the page sideways (fixed with overflow-wrap: anywhere)". The shorter filter here flags parents too; add the outermost and scroll-container checks from the lesson when the list gets noisy.
Quick Quiz
1. A 1280 px wide browser window is zoomed to 400%. How many CSS pixels wide is the viewport?
Zoom divides the CSS width: 1280 / 4 = 320, which is the WCAG 1.4.10 test width.
2. Which CSS change lets a flex item with a long word shrink inside its container?
Flex items default to min-width: auto; setting it to 0 allows them to shrink below their content.
3. In the lesson's test, why did the 768 px screenshot fail when the overflow check passed?
Screenshot comparison catches layout changes that do not cause overflow.
4. Which content may scroll sideways under WCAG 1.4.10 Reflow?
Content that needs two-dimensional layout, such as data tables and maps, is an allowed exception.
Learn HTML with a mentor
Free lessons get you started. Our Full Stack Web Development training adds real projects and code reviews from working developers.
- Project-based learning
- Mentor code reviews
- Free counselling call
