Sub topic 3
Setting up a fair comparison
This chapter assumes you know basic HTML and CSS (the box model, selectors, units) and can open browser DevTools. It also assumes you can read a design file such as a Figma frame or a PDF spec.
A visual QA pass only works if the built page and the design are compared under the same conditions. If they are not, you will report differences that do not exist and miss ones that do. Four things need to match: the browser, the viewport, the zoom level and the pixel density.
Pick one reference browser
Start in a single, current browser, usually the one the team treats as primary. Use a clean profile or a private window. Extensions that inject CSS, change fonts or darken pages will skew what you see. Cross-browser differences are a separate check, covered later in this tutorial.
Match the viewport to the design frame
Designs are drawn at fixed widths, for example 1440 px for desktop or 375 px for mobile. Find the frame width in the design file, then set the browser to the same width.
- Open DevTools and switch on the device toolbar (responsive mode).
- Enter the exact width from the design frame.
- Reload the page, because some scripts read the width only on load.
Check how the scrollbar is handled. A classic scrollbar takes about 15 px from the layout width on some systems, so a 1440 px window may give the page only 1425 px. Overlay scrollbars, which are common on macOS, do not do this.
Reset zoom
Browser zoom changes the CSS pixel width of the viewport. At 110% zoom, a 1440 px window gives the page about 1309 CSS pixels. Reset it to 100% (Ctrl/Cmd + 0) before measuring. Also check that the operating system's text scaling is at its default.
Account for pixel density
Many screens have a device pixel ratio (DPR) above 1. A DPR of 2 means one CSS pixel is drawn with 2 × 2 physical pixels. Designs are usually specified in CSS pixels, so compare in CSS pixels, not in screenshot pixels. You can read the current ratio in the console:
console.log({
dpr: window.devicePixelRatio,
viewportWidth: window.innerWidth,
viewportHeight: window.innerHeight,
zoomedPageWidth: document.documentElement.clientWidth
});If dpr is not 1 at 100% zoom, you are on a high-density screen. That is fine, but export design screenshots and take page screenshots at the same ratio before you overlay them.
Match the page state
Make sure the page shows the same content and state as the design:
- The same language and sample text, or note where they differ.
- The same logged-in or logged-out state.
- Cookie banners, chat widgets and feature flags dismissed or fixed.
- Web fonts fully loaded. Wait for the page to finish loading, then check in the console that no font is still pending.
document.fonts.ready.then(() => {
console.log('Fonts loaded:', document.fonts.size);
});Exercise
The design frame is 1440 px wide. You open the page in a 1440 px window with browser zoom at 125%, and the header looks smaller than in the design. What went wrong, and how do you fix it?
Show answer
At 125% zoom, the page gets only about 1152 CSS pixels (1440 ÷ 1.25), so the layout is at a different width than the design and the comparison is unfair. Reset zoom to 100% (Ctrl/Cmd + 0), confirm the viewport is 1440 CSS pixels wide, and compare again.