Sub topic 13
Checking that it looks clickable
This chapter assumes you can write basic HTML and CSS, know selectors and pseudo-classes, and can open your browser's developer tools. It closes the tutorial by turning the earlier design choices into a short test routine you can run on any page.
Why test at all
A button can look right in a design file and still fail in a browser. Colors shift on real screens, focus outlines get removed by a reset stylesheet, and small targets are hard to hit on a phone. A short, repeatable check catches these problems before users do.
The checks below map to earlier chapters: keyboard focus, contrast, target size, states, and labels.
Check 1: the keyboard pass
Put the mouse aside and press Tab from the top of the page. Then check three things:
- Every button and link receives focus, in a sensible order.
- A visible outline or other indicator shows where focus is.
- Enter activates links, and Enter or Space activates buttons.
If an element is skipped, it is probably a div or span with a click handler. Replace it with a real <button> or <a href>. If you can't see focus, look for outline: none in your CSS and replace it with a :focus-visible style.
Check 2: contrast
Text and key boundaries need enough contrast against their background. WCAG asks for at least 4.5:1 for normal text and 3:1 for large text and for the boundaries of interface components.
In Chrome or Edge, right-click an element, choose Inspect, and click its color swatch in the Styles pane. The color picker shows the contrast ratio and marks whether it passes. Check each state, not just the default one.
To test whether color is the only cue, set your display to grayscale or use the rendering emulation in DevTools to simulate color vision deficiencies. Links inside paragraphs should still stand out because of their underline.
Check 3: target size and spacing
Select a button in DevTools and look at the box model diagram. The rendered height and width should be at least 44px for primary touch targets. WCAG 2.2 sets a minimum of 24 by 24 CSS pixels, with 44px as the safer goal.
Inline links in sentences are exempt from the size rule, but links in lists or navigation bars need enough space between them to avoid mis-taps. You can also open device mode in DevTools and tap with the touch emulation on.
Check 4: states
You can force states without moving the mouse. In the Styles pane, click :hov and tick :hover, :active, :focus, or :focus-visible. Compare each state with the default. A good state change is visible without being dramatic.
The aria-disabled pattern needs its own test. Confirm that the button stays focusable, looks unavailable, and does nothing on activation.
Check 5: labels
Read each control without its surroundings. "Click here" and "Read more" fail this test because they say nothing on their own. A screen reader user often hears a list of links out of context, so each label has to make sense by itself. "Download the 2026 price list" works. "Save changes" works better than "Submit".
A script to speed up the audit
This script lists focusable elements whose rendered size is below 24px, and flags clickable-looking elements that aren't real buttons or links. Paste it into the DevTools console.
const small = [];
const fake = [];
document.querySelectorAll('a[href], button').forEach((el) => {
const { width, height } = el.getBoundingClientRect();
const isInlineLink = el.tagName === 'A' && getComputedStyle(el).display === 'inline';
if (!isInlineLink && (width < 24 || height < 24)) {
small.push(el);
}
});
document.querySelectorAll('[onclick], [role="button"]').forEach((el) => {
if (!['A', 'BUTTON'].includes(el.tagName)) {
fake.push(el);
}
});
console.log('Targets under 24px:', small);
console.log('Clickable non-button elements:', fake);The script finds common problems but can't judge appearance. You still need your eyes for the rest.
A quick summary table
| Check | Tool | Pass condition |
|---|---|---|
| Keyboard | Tab key | Every control reachable, focus visible |
| Contrast | DevTools color picker | 4.5:1 text, 3:1 component edges |
| Target size | Box model, device mode | At least 24px, ideally 44px |
| States | `:hov` panel | Hover, active, focus all distinct |
| Labels | Reading out of context | Each label describes its result |
Exercise
A teammate's page has a "Buy now" element built as a styled div with an onclick handler. Name two keyboard-pass failures you would expect, and give the fix.
Show answer
The div can't receive focus with Tab, and it doesn't respond to Enter or Space. The fix is to use a real <button type="button"> (or an <a href> if it navigates), which gives focus and keyboard activation for free. Then style it with a :focus-visible outline.
Exercise
Your secondary button has blue text (#3b82f6) on a white background. In DevTools the contrast ratio reads 3.7:1. Does it pass for its label text, and what would you do?
Show answer
It fails for normal-size label text, which needs 4.5:1. Darken the color, for example to #1d4ed8, and recheck the ratio in the color picker for the default, hover, and focus states.