Sub topic 13
Checking your groupings with the squint test
This chapter assumes you have read the earlier chapters of this tutorial. You should know the proximity principle, be able to use a spacing scale made of CSS custom properties, and understand padding, margin and gap. You should also be comfortable opening browser DevTools and running a line of JavaScript in the console.
What the squint test checks
You have built groups with spacing. Now you need to know whether a visitor sees the groups you meant. You wrote the page, so you already know which label belongs to which input. You cannot judge that by reading it.
The squint test removes the reading. You blur the page until the text is unreadable and look only at the shapes. Each cluster of content becomes a blob, and the gaps between blobs show up as lighter channels. You then compare what you see with what you intended.
The test answers three questions:
- Can you count the groups? The number of blobs should match the number of groups in your design.
- Is the nesting visible? Blobs inside blobs should read as sub-groups, and the gaps should get wider as you move up a level.
- Does anything float? An element that sits at an equal distance from two groups looks like it belongs to neither, or to both.
The test checks proximity only. It does not tell you whether contrast, wording or hierarchy work. Treat it as one pass in an audit, not the whole audit.
Running the test
You can squint at a physical screen, but a blur filter gives you the same result every time. Add a class that blurs the whole page and toggle it from the console. You don't need to edit your stylesheet.
.squint {
filter: blur(5px) grayscale(1);
}document.documentElement.classList.toggle("squint");To use these without touching your source files, paste this into the console. It injects the rule and toggles it in one step:
(() => {
const id = "squint-style";
let style = document.getElementById(id);
if (!style) {
style = document.createElement("style");
style.id = id;
style.textContent = "html.squint { filter: blur(5px) grayscale(1); }";
document.head.appendChild(style);
}
document.documentElement.classList.toggle("squint");
})();The grayscale(1) part matters. Color can hold a group together even when spacing is weak. If you want to know whether spacing alone shows the grouping, remove the color. Run the test again without it later to see how much your colors help.
Choose the blur radius by the text size. For 16px body text, a radius of 4px to 6px makes words unreadable but keeps blocks, rows and gaps visible. A radius that is too small leaves you reading. A radius that is too large turns the page into a single smear.
Some details to keep in mind:
- Blur at the viewport size you care about. A desktop layout can pass while the phone layout fails. Test at a narrow width and at a wide one.
- A filter on the root element changes how
position: fixedelements behave, because the filter makes the root their containing block. Sticky headers can shift while the filter is on. This only matters for the test and not for your production CSS. - Remove the filter before you measure anything. Measurements are unaffected by blur, but you will start to trust shapes you can't actually read.
Reading the result
Take a screenshot of the blurred page and mark the blobs you see. Then compare your marks with the structure you intended. Work from the outside in.
- Find the major sections. There should be clear horizontal bands separated by the widest gaps on the page.
- Within each section, find the sub-groups: cards, form groups, a heading with its paragraphs.
- Within each sub-group, check that the smallest gaps join the closest pairs, such as a label and its input.
- Look for orphans: elements that don't clearly join any blob.
You can also express this as a ratio rule. Each level of grouping should have a visibly larger gap than the level inside it. A step of 1.5 times or more between levels is a reasonable minimum. On the spacing scale from this tutorial, that means moving at least one or two steps up. The form from the earlier chapter used --space-1 (0.25rem) between label and input, --space-3 (1rem) between fields, and --space-5 (2.5rem) between groups. Those ratios are 4 and 2.5, so the structure survives blurring easily.
Measuring when your eyes disagree
Sometimes a blob looks wrong and you can't tell why. Measure the gaps instead of guessing. This function reports the vertical distance between each pair of consecutive children of an element.
function gaps(container) {
const kids = [...container.children];
return kids.slice(1).map((el, i) => {
const prev = kids[i].getBoundingClientRect();
const cur = el.getBoundingClientRect();
return {
between: `${kids[i].tagName.toLowerCase()} to ${el.tagName.toLowerCase()}`,
gap: Math.round(cur.top - prev.bottom),
};
});
}
console.table(gaps(document.querySelector("form")));Run it on a container such as a form, a card list or a main element, and read the numbers. You want a clear sequence: small values inside groups, larger values between groups. A table like 4, 4, 40, 4 is a healthy form. A table like 16, 16, 16, 16 means every element is equally far from every other, so nothing is grouped.
This function measures the stacked, one-column case. It uses the vertical distance between boxes, so it will give misleading numbers for children laid out side by side in a grid row. In that case, compare left and right edges instead.
Common failures and their fixes
| What you see when blurred | Likely cause | Fix |
|---|---|---|
| Everything is one even column of blobs | One spacing value used everywhere, often a global margin on every element | Use the scale: small gaps inside groups, larger gaps between them |
| A heading sits midway between two paragraphs | Equal `margin-top` and `margin-bottom` on headings | Give the heading much more space above than below |
| A label joins the previous input instead of its own | Label has the same distance to both neighbors | Reduce the label-to-input gap, or increase the field-to-field gap |
| Cards in a grid look like one big block | Gap between cards is smaller than the padding inside them | Make the grid gap at least as large as the card padding, or add a border or background |
| A gap looks larger than any token | Padding and margin are adding together, or margins did not collapse as expected | Inspect the box model and use `gap` for sibling spacing |
| Groups look fine on desktop but merge on mobile | Spacing is fixed in `rem` and the layout became one column | Use a responsive token such as `clamp()` for section spacing |
The fourth row is common. When padding inside a card is larger than the space between cards, the content of one card is closer to the next card's edge than to its own edge. Blurring shows the card's content as floating and the grid as a single mass. Compare the card padding with the grid gap and keep the gap equal to or larger than the padding.
Edge cases and limits of the test
The squint test can mislead you in a few situations.
- Borders and backgrounds. A border or a filled background creates a group by enclosure, which is stronger than proximity. Blurring shows these as bold shapes, so your spacing can be weak and still pass. If you want to know whether the spacing alone works, turn the borders and backgrounds off in DevTools and blur again. If you intend to rely on enclosure, that is fine, but know that you are doing so.
- Low contrast. A pale gray card on a white page may vanish under blur. If it vanishes, your visitors on a poor screen or in bright light may not see it either.
- Images. A large photo is one huge dark blob and will dominate the view. Judge the text groups around it separately, and check that captions sit closer to their images than to the next item.
- Dense data. Tables and long lists blur into stripes. For these, check that row spacing is regular and that header rows are separated from the body.
- Different viewers. People with low vision experience blur naturally, and some zoom in so far that only a few lines are visible at once. The test approximates the first case. It does not replace testing with zoom at 200 percent.
Pairing it with the text-spacing check
Your layout also has to hold up when users override text spacing. The WCAG 1.4.12 stylesheet from the accessibility chapter forces larger line height, letter spacing, word spacing and paragraph spacing. Apply it, then blur the page again.
* {
line-height: 1.5 !important;
letter-spacing: 0.12em !important;
word-spacing: 0.16em !important;
}
p {
margin-bottom: 2em !important;
}Check two things. First, do the blobs stay in the same groups, or did the larger paragraph margin make a paragraph drift toward the next heading? Second, did any text overflow, clip or overlap? If a group falls apart under the override, the usual cause is spacing set in fixed pixel heights or in margins that don't scale with the text. Replace fixed heights with min-height or padding, and keep spacing in rem or em.
A short audit routine
Use this routine on any page before you ship it.
- Open the page at a desktop width and toggle the squint class. Mark the blobs.
- Compare the blobs with the intended structure. Note every mismatch.
- Run
gaps()on each container that looks wrong. Fix the offending token, not just one element. - Resize to a narrow width. Blur again and repeat.
- Apply the text-spacing stylesheet and blur once more.
- Turn off borders and backgrounds if you want to confirm the spacing works without them.
Fix the token or the shared rule whenever you can. If you patch one element with a custom margin, the same problem will return on the next page that uses the component.
Exercise
You blur a settings page and see one continuous column of equal-looking blobs. You run gaps() on the form and get 16, 16, 16, 16, 16, 16. Each label is 16px above its input, and each field is 16px above the next. What is wrong, and what change would you make using the spacing scale from this tutorial (--space-1 0.25rem, --space-3 1rem, --space-5 2.5rem)?
Show answer
Every element is the same distance from its neighbors, so proximity carries no information and nothing reads as a group. Make the gaps follow the relationships: put --space-1 between each label and its input, keep --space-3 between fields in the same group, and put --space-5 between groups. For example, set .field { display: grid; gap: var(--space-1); }, .group { display: grid; gap: var(--space-3); } and .form { display: grid; gap: var(--space-5); }. Then blur again and re-run gaps(). The numbers should now show a pattern of small, medium and large values that match the nesting.