Loading...
Loading...
Uses Chrome DevTools MCP for accessibility (a11y) debugging and auditing based on web.dev guidelines. Use when testing semantic HTML, ARIA labels, focus states, keyboard navigation, tap targets, and color contrast.
npx skill4agent add chromedevtools/chrome-devtools-mcp a11y-debuggingCSS opacity: 0display: nonearia-hidden="true"take_snapshothttps://web.dev/articles/accessible-tap-targets.md.txthttps://web.dev/articles/accessible-tap-targets.md.txtlist_console_messagestypes["issue"]includePreservedMessagestruetake_snapshoth1h2h3take_screenshottake_snapshot""evaluate_scriptidlabel[for]aria-label() =>
Array.from(document.querySelectorAll('input, select, textarea'))
.filter(i => {
const hasId = i.id && document.querySelector(`label[for="${i.id}"]`);
const hasAria =
i.getAttribute('aria-label') || i.getAttribute('aria-labelledby');
return !hasId && !hasAria && !i.closest('label');
})
.map(i => ({
tag: i.tagName,
id: i.id,
name: i.name,
placeholder: i.placeholder,
}));
4. Check images for `alt` text.
### 4. Focus & Keyboard Navigation
Testing "keyboard traps" and proper focus management without visual feedback relies on tracking the focused element.
1. Use the `press_key` tool with `"Tab"` or `"Shift+Tab"` to move focus.
2. Use `take_snapshot` to capture the updated accessibility tree.
3. Locate the element marked as focused in the snapshot to verify focus moved to the expected interactive element.
4. If a modal opens, focus must move into the modal and "trap" within it until closed.
### 5. Tap Targets and Visuals
According to web.dev, tap targets should be at least 48x48 pixels with sufficient spacing. Since the accessibility tree doesn't show sizes, use `evaluate_script`:
```js
// Usage in console: copy, paste, and call with element: fn(element)
el => {
const rect = el.getBoundingClientRect();
return {width: rect.width, height: rect.height};
};uidevaluate_scriptlist_console_messagestypes: ["issue"]axe-coreel => {
function getRGB(colorStr) {
const match = colorStr.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
return match
? [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])]
: [255, 255, 255];
}
function luminance(r, g, b) {
const a = [r, g, b].map(function (v) {
v /= 255;
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
});
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
}
const style = window.getComputedStyle(el);
const fg = getRGB(style.color);
let bg = getRGB(style.backgroundColor);
// Basic contrast calculation (Note: Doesn't account for transparency over background images)
const l1 = luminance(fg[0], fg[1], fg[2]);
const l2 = luminance(bg[0], bg[1], bg[2]);
const ratio = (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
return {
color: style.color,
bg: style.backgroundColor,
contrastRatio: ratio.toFixed(2),
};
};uid() => ({
lang:
document.documentElement.lang ||
'MISSING - Screen readers need this for pronunciation',
title: document.title || 'MISSING - Required for context',
viewport:
document.querySelector('meta[name="viewport"]')?.content ||
'MISSING - Check for user-scalable=no (bad practice)',
reducedMotion: window.matchMedia('(prefers-reduced-motion: reduce)').matches
? 'Enabled'
: 'Disabled',
});evaluate_scripttake_screenshot