{"meta":{"title":"辅助功能审核者","intro":"全面的 Web 辅助功能测试与合规性说明。","product":"GitHub Copilot","breadcrumbs":[{"href":"/zh/copilot","title":"GitHub Copilot"},{"href":"/zh/copilot/tutorials","title":"教程"},{"href":"/zh/copilot/tutorials/customization-library","title":"定制化库"},{"href":"/zh/copilot/tutorials/customization-library/custom-instructions","title":"自定义说明"},{"href":"/zh/copilot/tutorials/customization-library/custom-instructions/accessibility-auditor","title":"辅助功能审核者"}],"documentType":"article"},"body":"# 辅助功能审核者\n\n全面的 Web 辅助功能测试与合规性说明。\n\n> \\[!NOTE]\n>\n> * 此库中的示例旨在提供灵感，建议进行相应调整，使其更特定于你的项目、语言和团队流程。\n> * 如需获取社区提供的有关特定语言和场景的自定义指令示例，请参阅[出色的 GitHub Copilot 自定义内容](https://github.com/github/awesome-copilot/blob/main/docs/README.instructions.md)仓库。\n> * 可以跨不同范围应用自定义指令，具体取决于要在其中创建自定义指令的平台或 IDE。 有关详细信息，请参阅“[关于自定义GitHub Copilot 响应](/zh/copilot/concepts/prompting/response-customization)”。\n\n下面的示例展示了一个路径专用的 `accessibility.instructions.md` 文件，它仅适用于代码库中的 HTML 文件，并引导 GitHub Copilot 生成符合 WCAG 指南的、可访问且具有包容性的 HTML。 有关特定于路径的说明文件的详细信息，请参阅 [为GitHub Copilot添加存储库自定义说明](/zh/copilot/how-tos/copilot-on-github/customize-copilot/add-custom-instructions/add-repository-instructions#creating-path-specific-custom-instructions)。\n\n````text copy\n---\napplyTo: **/*.html\n---\n\nWhen generating code, ensure accessibility compliance by following these priorities:\n\n## Semantic HTML First\n- Use proper semantic elements: `<nav>`, `<main>`, `<section>`, `<article>`, `<header>`, `<footer>`\n- Structure headings sequentially (h1 → h2 → h3, never skip levels)\n- Use one `<h1>` per page with descriptive heading text\n\n## Essential ARIA Requirements\n- Add `alt` text to all images\n- Label form inputs with `<label>` or `aria-label`\n- Ensure interactive elements have accessible names\n- Use `aria-expanded` for collapsible content\n- Add `role`, `aria-labelledby`, and `aria-describedby` when semantic HTML isn't sufficient\n\n## Keyboard Navigation\n- All interactive elements must be keyboard accessible\n- Provide visible focus indicators (minimum 2px outline)\n- Include skip links: `<a href=\"#main\">Skip to main content</a>`\n- Use logical tab order that matches visual layout\n\n## Color and Contrast\n- Ensure 4.5:1 contrast ratio for normal text, 3:1 for large text\n- Don't rely solely on color to convey information\n\n## Quick Test Questions\n- Can you navigate the entire interface using only Tab/Shift+Tab/Enter?\n- Are all images and icons properly described?\n- Can screen reader users understand the content and functionality?\n\n## Screen Reader Compatibility\n\n**Provide descriptive text for all non-text content:**\n- Images: Use alt text that describes function, not just appearance\n  - Good: `alt=\"Submit form\"`\n  - Avoid: `alt=\"Blue button\"`\n- Form inputs: Associate every input with a `<label>` element\n- Links: Use descriptive link text\n  - Good: \"Download the accessibility report (PDF, 2MB)\"\n  - Avoid: \"Click here\" or \"Read more\"\n\n**Announce dynamic content updates:**\n- Use `aria-live=\"polite\"` for status updates\n- Use `aria-live=\"assertive\"` for urgent notifications\n- Update screen reader users when content changes without page reload\n\n---\n\n## Color and Contrast Requirements\n\n**Meet these specific contrast ratios:**\n- Normal text (under 18pt): Minimum 4.5:1 contrast ratio\n- Large text (18pt+ or 14pt+ bold): Minimum 3:1 contrast ratio\n- UI components and graphics: Minimum 3:1 contrast ratio\n\n**Provide multiple visual cues:**\n- Use color + icon + text for status indicators\n- Add patterns or textures to distinguish chart elements\n- Include text labels on graphs and data visualizations\n\n---\n\n## Testing Integration Steps\n\n**Include these automated checks:**\n1. Run axe-core accessibility scanner in CI/CD pipeline\n2. Test with lighthouse accessibility audit\n3. Validate HTML markup for semantic correctness\n\n**Perform these manual tests:**\n1. Navigate entire interface using only Tab and arrow keys\n2. Test with screen reader (NVDA on Windows, VoiceOver on Mac)\n3. Verify 200% zoom doesn't break layout or hide content\n4. Check color contrast with tools like WebAIM Color Contrast Checker\n\n---\n\n## Form Design Standards\n\n**Create accessible form experiences:**\n- Place labels above or to the left of form fields\n- Group related fields with `<fieldset>` and `<legend>`\n- Display validation errors immediately after the field with `aria-describedby`\n- Use `aria-required=\"true\"` for required fields\n- Provide clear instructions before users start filling out forms\n\n**Error message format:**\n```html\n<input aria-describedby=\"email-error\" aria-invalid=\"true\">\n<div id=\"email-error\">Please enter a valid email address</div>\n```\n\n---\n\n**Code Generation Rule:** Always include accessibility comments explaining ARIA attributes and semantic choices. Test code with keyboard navigation before suggesting it's complete.\n\n````\n\n## 其他阅读材料\n\n* [关于自定义GitHub Copilot 响应](/zh/copilot/concepts/prompting/response-customization) - GitHub Copilot 中的响应自定义概述\n* [为 Copilot 添加自定义说明](/zh/copilot/how-tos/copilot-on-github/customize-copilot/add-custom-instructions) - 如何配置自定义指令\n* [出色的 GitHub Copilot 自定义内容](https://github.com/github/awesome-copilot/blob/main/README.md) - 社区提供的自定义指令的仓库以及特定语言和场景的其他自定义内容"}