accessibility
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWeb Accessibility (WCAG 2.2 AA)
Web无障碍设计(WCAG 2.2 AA)
Build for everyone — accessibility is a requirement, not a feature.
为所有人而构建——无障碍设计是一项要求,而非附加功能。
Contrast Ratios (WCAG AA)
对比度标准(WCAG AA)
| Element | Minimum Ratio |
|---|---|
| Normal text (< 18pt) | 4.5:1 |
| Large text (>= 18pt or 14pt bold) | 3:1 |
| UI components and focus indicators | 3:1 |
| 元素类型 | 最低对比度 |
|---|---|
| 常规文本(<18磅) | 4.5:1 |
| 大文本(≥18磅或14磅粗体) | 3:1 |
| UI组件和焦点指示器 | 3:1 |
WCAG 2.2 New AA Criteria
WCAG 2.2新增AA级标准
| Criterion | Requirement |
|---|---|
| Target Size Minimum (2.5.8) | Interactive targets at least 24x24 CSS pixels |
| Focus Not Obscured Minimum (2.4.11) | Focused element at least partially visible, not hidden by sticky headers or overlays |
| Focus Appearance (2.4.13) | Focus indicator has minimum area (2px perimeter) and 3:1 contrast change |
| Dragging Movements (2.5.7) | Provide single-pointer alternative for any drag interaction |
| Redundant Entry (3.3.7) | Do not require re-entering previously provided information |
| Consistent Help (3.2.6) | Help mechanisms (chat, phone, FAQ) appear in same relative order across pages |
| Accessible Authentication (3.3.8) | No cognitive function test for login (allow paste, autofill, or alternatives) |
| 准则名称 | 要求内容 |
|---|---|
| 最小目标尺寸(2.5.8) | 交互目标至少为24x24 CSS像素 |
| 焦点不被遮挡(2.4.11) | 聚焦元素至少部分可见,不被固定页眉或覆盖层隐藏 |
| 焦点外观(2.4.13) | 焦点指示器需满足最小面积(2px边框)和3:1的对比度变化 |
| 拖拽操作替代方案(2.5.7) | 为所有拖拽交互提供单指针替代操作 |
| 避免重复输入(3.3.7) | 不要求重复输入已提供的信息 |
| 一致的帮助机制(3.2.6) | 帮助机制(聊天、电话、FAQ)在所有页面中的相对位置保持一致 |
| 无障碍身份验证(3.3.8) | 登录过程不包含认知功能测试(允许粘贴、自动填充或提供替代方式) |
Essential Keyboard Patterns
核心键盘操作模式
| Key | Action |
|---|---|
| Tab / Shift+Tab | Navigate between focusable elements |
| Enter / Space | Activate buttons and links |
| Arrow keys | Navigate within widgets (tabs, menus) |
| Escape | Close dialogs and menus |
| Home / End | Jump to first/last item in widget |
| 按键组合 | 操作说明 |
|---|---|
| Tab / Shift+Tab | 在可聚焦元素间导航 |
| Enter / Space | 激活按钮和链接 |
| 方向键 | 在组件内导航(标签页、菜单) |
| Escape | 关闭对话框和菜单 |
| Home / End | 跳转到组件内的第一个/最后一个项 |
Element Selection
元素选择指南
| Need | Element |
|---|---|
| Navigates to page | |
| Submits form | |
| Opens dialog | |
| Other action | |
| Self-contained article | |
| Navigation links | |
| Supplementary info | |
| 需求场景 | 推荐元素 |
|---|---|
| 跳转到其他页面 | |
| 提交表单 | |
| 打开对话框 | |
| 其他操作 | |
| 独立文章内容 | |
| 导航链接集合 | |
| 补充信息 | |
Common ARIA Attributes
常用ARIA属性
| Attribute | Purpose |
|---|---|
| Name when no visible label exists |
| Reference existing text as label |
| Additional description (hints, errors) |
| Announce dynamic updates ( |
| Collapsible/expandable state |
| Hide decorative elements from screen readers |
| Mark form fields with errors |
| Mark required fields |
| Indicate loading state |
| 属性名称 | 用途 |
|---|---|
| 当无可见标签时提供名称 |
| 引用现有文本作为标签 |
| 提供额外描述(提示、错误信息) |
| 播报动态更新( |
| 标记可折叠/展开状态 |
| 向屏幕阅读器隐藏装饰性元素 |
| 标记存在错误的表单字段 |
| 标记必填字段 |
| 指示加载状态 |
WCAG 2.2 AA Checklist Summary
WCAG 2.2 AA标准检查清单摘要
| Principle | Key Requirements |
|---|---|
| Perceivable | Alt text on images, contrast >= 4.5:1, color not sole indicator, text resizable to 200%, captions on video, |
| Operable | Keyboard accessible, visible focus not obscured, focus appearance meets minimum, targets >= 24px, skip links, dragging alternatives |
| Understandable | |
| Robust | Valid HTML, name/role/value on all UI components, |
| 原则 | 核心要求 |
|---|---|
| 可感知 | 图片添加替代文本、对比度≥4.5:1、不单独依赖颜色作为标识、文本可放大至200%、视频添加字幕、支持 |
| 可操作 | 支持键盘操作、焦点可见且不被遮挡、焦点外观符合标准、交互目标≥24px、提供跳转链接、拖拽操作替代方案 |
| 可理解 | 设置 |
| 健壮性 | 有效的HTML、所有UI组件具备名称/角色/值、状态消息使用 |
Anti-Patterns
反模式示例
| Anti-Pattern | Fix |
|---|---|
| Use semantic HTML elements |
| Use |
| Placeholder as label | Use |
| Use DOM order or |
| Color-only state indicators | Add icon and text label |
| Skipped heading levels | Use sequential h1-h6, style with CSS |
| Remove redundant ARIA |
| Never hide interactive content |
| Fixed font sizes (px) | Use |
| No focus trap in modal dialogs | Trap focus, close on Escape |
| 反模式 | 修复方案 |
|---|---|
使用 | 使用语义化HTML元素 |
移除 | 使用 |
| 用占位符作为标签 | 使用 |
| 使用DOM顺序或 |
| 仅依赖颜色作为状态指示器 | 添加图标和文本标签 |
| 跳过标题层级 | 按顺序使用h1-h6,通过CSS设置样式 |
在 | 移除冗余的ARIA属性 |
对交互元素设置 | 绝不要隐藏可交互内容 |
| 使用固定字体大小(px) | 使用 |
| 模态对话框未设置焦点陷阱 | 实现焦点陷阱,支持按Escape关闭 |
Common Mistakes
常见错误
| Mistake | Correct Pattern |
|---|---|
Adding | Use |
Using | Use |
Setting | Provide descriptive alt text; only use empty alt on purely decorative images |
| Adding keyboard handlers to non-focusable elements | Use native interactive elements or add |
| Testing only with automated tools like axe | Automated scans catch ~30% of issues; always supplement with keyboard-only and screen reader testing |
| 错误做法 | 正确实现方式 |
|---|---|
为已有可见文本的元素添加 | 改用 |
对非紧急更新使用 | 大多数动态内容使用 |
对有意义的图片设置 | 提供描述性替代文本;仅对纯装饰性图片使用空alt值 |
| 为不可聚焦元素添加键盘事件处理程序 | 使用原生交互元素,或添加 |
| 仅使用axe等自动化工具测试 | 自动化扫描仅能发现约30%的问题;务必补充纯键盘测试和屏幕阅读器测试 |
Screen Reader and Browser Pairings
屏幕阅读器与浏览器配对
| Screen Reader | Browser | Platform |
|---|---|---|
| JAWS | Chrome | Windows |
| NVDA | Chrome | Windows (free) |
| NVDA | Firefox | Windows (free) |
| VoiceOver | Safari | macOS / iOS |
| TalkBack | Chrome | Android |
| Narrator | Edge | Windows (built-in) |
| 屏幕阅读器 | 浏览器 | 平台 |
|---|---|---|
| JAWS | Chrome | Windows |
| NVDA | Chrome | Windows(免费) |
| NVDA | Firefox | Windows(免费) |
| VoiceOver | Safari | macOS / iOS |
| TalkBack | Chrome | Android |
| Narrator | Edge | Windows(内置) |
Testing Quick Guide
快速测试指南
| Method | Tool | Effort |
|---|---|---|
| Keyboard-only | Hide mouse, Tab through page | 5 min |
| Screen reader | JAWS + Chrome or NVDA + Chrome/Firefox | 10 min |
| Screen reader | VoiceOver + Safari (macOS) | 10 min |
| Automated scan | axe DevTools browser extension | 2 min |
| Lighthouse | Chrome F12 > Lighthouse > Accessibility | 2 min |
| Unit tests | jest-axe (Jest) or vitest-axe (Vitest) | Ongoing |
| 测试方法 | 工具 | 耗时 |
|---|---|---|
| 纯键盘测试 | 隐藏鼠标,按Tab遍历页面 | 5分钟 |
| 屏幕阅读器测试 | JAWS + Chrome 或 NVDA + Chrome/Firefox | 10分钟 |
| 屏幕阅读器测试 | VoiceOver + Safari(macOS) | 10分钟 |
| 自动化扫描 | axe DevTools浏览器扩展 | 2分钟 |
| Lighthouse测试 | Chrome F12 > Lighthouse > 无障碍选项 | 2分钟 |
| 单元测试 | jest-axe(Jest)或vitest-axe(Vitest) | 持续进行 |
Delegation
职责分工
When working on accessibility, delegate to:
- — Color tokens and contrast verification
design-system - — Component patterns and hooks
react-patterns - — jest-axe integration and test patterns
testing
处理无障碍设计工作时,可分工至:
- — 颜色令牌和对比度验证
design-system - — 组件模式和钩子
react-patterns - — jest-axe集成和测试模式
testing
Resources
参考资源
References
扩展参考
- Semantic HTML and Structure — Document landmarks, heading hierarchy, element selection, skip links
- Focus Management — Focus indicators, focus not obscured, dialog focus traps, SPA route focus, focus-visible patterns
- ARIA Patterns — Accessible tabs, live regions, data tables with ARIA attributes
- Forms and Validation — Label association, error announcement, redundant entry, accessible authentication
- Color and Media — Contrast requirements, reduced motion, dragging alternatives, video captions, alt text
- Testing — Keyboard testing, screen reader pairings, axe DevTools, jest-axe and vitest-axe unit tests
- 语义化HTML与结构 — 文档地标、标题层级、元素选择、跳转链接
- 焦点管理 — 焦点指示器、焦点不被遮挡、对话框焦点陷阱、SPA路由焦点、:focus-visible模式
- ARIA模式 — 无障碍标签页、实时区域、带ARIA属性的数据表格
- 表单与验证 — 标签关联、错误播报、避免重复输入、无障碍身份验证
- 颜色与媒体 — 对比度要求、减少动画、拖拽替代方案、视频字幕、替代文本
- 测试方法 — 键盘测试、屏幕阅读器配对、axe DevTools、jest-axe和vitest-axe单元测试