Sub topic 2
Layout, Alignment, Spacing, and Visual Details
Assume you know the CSS box model, selectors, common units, browser DevTools, and how to read a Figma frame or style guide. This chapter focuses on visual comparison after the page has been built. It does not replace functional, semantic, or performance testing.
Layout, alignment, and spacing
Compare the same viewport in the design and browser. Check the page’s main container, column widths, gutters, padding, gaps, and alignment edges. Look for repeated relationships: cards should share widths, headings should align with body text, and controls should use consistent gaps.
Inspect the box model in DevTools rather than judging empty space by eye.
/* Paste into DevTools or a temporary stylesheet */
* {
outline: 1px solid rgba(255, 0, 0, 0.4);
}Separate a layout error from a content error. A card may appear too tall because its padding is wrong, or because the heading wraps onto an extra line.
Typography
Check the loaded font family, fallback behavior, font size, weight, line height, and letter spacing. A small font difference can change wrapping and shift every element below it.
const el = document.querySelector("h1");
const s = getComputedStyle(el);
console.log({
fontFamily: s.fontFamily,
fontSize: s.fontSize,
fontWeight: s.fontWeight,
lineHeight: s.lineHeight,
letterSpacing: s.letterSpacing,
color: s.color
});Confirm that the browser loaded the intended font. A synthetic bold or fallback font can make text wider even when the CSS values look correct.
Color and contrast
Compare actual computed colors with design tokens, not approximate screen colors. Check text, backgrounds, borders, links, and status colors in every relevant state. Normal body text should usually reach a contrast ratio of at least 4.5:1. Large text should reach at least 3:1.
Images, icons, and assets
Verify the asset, crop, aspect ratio, resolution, and alignment. Check whether an icon uses the intended stroke width and optical size. A technically correct SVG can still look misaligned because its viewBox contains extra whitespace.
Responsive breakpoints
Test the widths named in the design and the widths just before and after each breakpoint. Watch for abrupt jumps, overlapping content, clipped controls, and unexpected text wrapping.
Exercise
A card is 24 pixels taller than the design. Its padding matches, but its title wraps to two lines. What should you inspect first?
Show answer
Inspect the loaded font family, font size, weight, line height, available width, and letter spacing before changing the card height.