Research About How to Enforce WCAG 2.2 in Practice - bounswe/bounswe2024group1 GitHub Wiki
Implementing WCAG 2.2 in practice requires integrating accessibility standards into the development lifecycle. Here are some specific development examples:
-
Alt Text for Images: When adding images to a website, include descriptive alt text for each image. This allows screen readers to describe images to visually impaired users.
<img src="product.jpg" alt="Red leather handbag with adjustable strap">
-
Video Captions: Provide captions for video content to make it accessible for users with hearing impairments.
<video controls> <track kind="captions" src="captions_en.vtt" srclang="en" label="English"> </video>
-
Semantic HTML: Use HTML5 semantic tags (like
<header>
,<nav>
,<section>
,<footer>
) to define the structure, which screen readers rely on to help users navigate the page.<header> <h1>Company Name</h1> </header> <nav> <ul> <li><a href="#home">Home</a></li> <li><a href="#about">About</a></li> </ul> </nav>
-
Keyboard Navigation: Ensure all interactive elements can be accessed with a keyboard. Use JavaScript only when necessary and avoid interfering with native keyboard behaviors.
<button>Submit</button> <!-- Ensures buttons are focusable by default -->
-
Focus Indicators: Provide clear visual focus indicators on interactive elements,so keyboard users know which element is currently focused.
button:focus { outline: 2px solid blue; }
-
Adjustable Time Limits: For content with a time limit, provide a way for users to adjust or disable it.
let timer = setTimeout(() => { alert('Session timed out'); }, 60000); // 60 seconds function extendSession() { clearTimeout(timer); timer = setTimeout(() => { alert('Session timed out'); }, 60000); }
-
Readable Text: Write form labels and instructions in simple, clear language. Avoid jargon or provide definitions where necessary.
<label for="email">Email Address</label> <input type="email" id="email" name="email">
-
Consistent Interface Behavior: Avoid unexpected changes. For example, if a link opens a new window, provide a visual indication.
<a href="https://example.com" target="_blank" rel="noopener noreferrer"> Open in a new tab </a>
-
ARIA Roles and Attributes: For custom components, use ARIA roles to define their purpose and state for assistive technologies. For example, a custom button should include
role="button"
andaria-pressed="true"
if it functions like a toggle button.<div role="button" aria-pressed="false" tabindex="0" onclick="togglePressed(this)"> Toggle Option </div>
-
Focus Appearance: In WCAG 2.2, the focus indicator should be more visible. Ensure a strong color contrast for focus states and increase the indicator’s thickness if necessary.
button:focus { outline: 3px dashed #00f; outline-offset: 2px; }
-
Target Size: Ensure that interactive elements have a minimum size of 44x44 CSS pixels.
.button { width: 44px; height: 44px; }
-
Drag Movements: For interfaces that involve dragging, provide alternative controls for users who may struggle with drag-and-drop interactions.
function moveElement(direction) { // Function to move an element up, down, left, or right without dragging }