From the free course Computer Applications and Information Technology on Lykke
Web Development and Digital Accessibility
Key concepts: HTML · Web Accessibility Auditing · WCAG Standards · WAI-ARIA · Assistive Technology
An introduction to web technologies (HTML) and the critical standards for making digital content accessible to all users.
Web Development and Digital Accessibility
The modern web is often characterized by its visual flair and interactive complexity, yet its fundamental purpose remains the transmission of information. Digital Accessibility (often abbreviated as a11y) is the practice of ensuring that there are no barriers that prevent interaction with, or access to, websites by people with physical disabilities, situational disabilities, or socio-economic restrictions. In the context of professional web development, accessibility is not a "feature" to be added at the end of a project; it is a core architectural requirement, much like security or performance.
The Semantic Foundation: HTML and the Accessibility Tree
At the heart of every web page is HTML (HyperText Markup Language). While many developers view HTML merely as a tool for visual layout, its primary technical role is to provide semantic structure. Semantic HTML uses tags that convey the meaning of the content to the browser and, crucially, to Assistive Technology (AT).
When a browser renders a page, it creates two primary internal models:
- The DOM (Document Object Model): A tree representation of the HTML structure used for rendering and scripting.
- The Accessibility Tree: A subset of the DOM that contains only the information relevant to assistive technologies, such as screen readers.
Definition: The Accessibility Tree The Accessibility Tree is a specialized data structure generated by the browser engine that filters out purely presentational elements and exposes the name, role, state, and value of every interactive element to the OS-level accessibility APIs.
Semantic vs. Non-Semantic Implementation
The difference between semantic and non-semantic code is the difference between a machine "understanding" a button and a machine seeing a generic box.
| Feature | Non-Semantic (<div> / <span>) |
Semantic (<button>, <nav>, <header>) |
|---|---|---|
| Role Mapping | None (Generic) | Explicit (e.g., "Button", "Navigation") |
| Keyboard Focus | Requires tabindex="0" |
Automatic |
| Activation | Requires JS keydown listeners |
Automatic (Enter/Space keys) |
| AT Announcement | "Group" or nothing | "Submit, Button" |
| SEO Impact | Low | High |
Implementation Example: The Custom Toggle
The following JavaScript implementation demonstrates how to programmatically manage accessibility states for a custom component that cannot be represented by a simple native element.
/**
* AccessibleToggle: A class to manage a custom toggle switch.
* Ensures that the DOM state and the Accessibility Tree stay in sync.
*/
class AccessibleToggle {
constructor(elementId) {
this.button = document.getElementById(elementId);
this.state = {
pressed: this.button.getAttribute('aria-pressed') === 'true'
};
this.init();
}
init() {
// Ensure the element has the correct ARIA role if not using <button>
if (this.button.tagName !== 'BUTTON') {
this.button.setAttribute('role', 'button');
this.button.setAttribute('tabindex', '0');
}
this.button.addEventListener('click', () => this.toggle());
this.button.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
this.toggle();
}
});
}
toggle() {
this.state.pressed = !this.state.pressed;
// Update the Accessibility Tree via ARIA attributes
this.button.setAttribute('aria-pressed', this.state.pressed);
// Visual update (CSS handles the rest via attribute selector)
this.button.classList.toggle('is-active', this.state.pressed);
// Dispatch custom event for application logic
this.button.dispatchEvent(new CustomEvent('toggleChange', {
detail: { pressed: this.state.pressed }
}));
}
}
// Usage
const mySwitch = new AccessibleToggle('theme-switcher');
WCAG Standards: The POUR Principles
The Web Content Accessibility Guidelines (WCAG), developed by the W3C, serve as the international benchmark for digital inclusion. WCAG is organized under four foundational principles, known by the acronym POUR.
- Perceivable: Information and user interface components must be presentable to users in ways they can perceive (it can't be invisible to all their senses).
- Operable: User interface components and navigation must be operable (the user must be able to operate the interface).
- Understandable: Information and the operation of the user interface must be understandable.
- Robust: Content must be robust enough that it can be interpreted reliably by a wide variety of user agents, including assistive technologies.
WCAG Conformance Levels
WCAG is categorized into three levels of compliance, representing increasing degrees of accessibility.
| Level | Description | Target Audience |
|---|---|---|
| Level A | The minimum level of accessibility. Without meeting these, the site is nearly impossible for some to use. | Essential for all sites. |
| Level AA | The global standard for most commercial and government sites. Addresses the most common barriers. | Professional/Legal standard. |
| Level AAA | The highest and most complex level. Often requires significant design trade-offs. | Specialized/Dedicated sites. |
Mathematical Derivation of Color Contrast
One of the most common WCAG AA requirements is a contrast ratio of at least 4.5:1 for normal text. This is calculated using the relative luminance ($L$) of the colors.
The relative luminance $L$ of a color is defined as: $$L = 0.2126R + 0.7152G + 0.0722B$$ where $R, G, B$ are the sRGB components, linearized.
The contrast ratio is then calculated as: $$Contrast = \frac{L_1 + 0.05}{L_2 + 0.05}$$ where $L_1$ is the luminance of the lighter color and $L_2$ is the luminance of the darker color.
WAI-ARIA: Bridging the Semantic Gap
WAI-ARIA (Web Accessibility Initiative – Accessible Rich Internet Applications) is a technical specification that provides a way to add missing semantic information to HTML. It is particularly vital for dynamic web applications where content changes without a page reload.
ARIA is comprised of three main features:
- Roles: Define what an element is (e.g.,
role="tablist",role="alert"). - Properties: Define characteristics of elements (e.g.,
aria-haspopup="true"). - States: Define the current condition of an element (e.g.,
aria-disabled="true",aria-expanded="false").
The First Rule of ARIA If you can use a native HTML element or attribute with the semantics and behavior you require already built-in, then do so. Do not use ARIA unless you absolutely have to.
ARIA Logic Flow
The following pseudocode describes the logic a developer must follow when determining whether to implement ARIA for a custom UI component.
FUNCTION DetermineAriaRequirement(component):
IF component.hasNativeEquivalent() THEN
RETURN "Use Semantic HTML (e.g., <details> instead of ARIA-accordion)"
IF component.isInteractive() THEN
SET role = MapToAriaRole(component.type)
SET tabIndex = 0
ADD KeyboardEventListeners(['Space', 'Enter', 'Arrows'])
IF component.contentChangesDynamically() THEN
SET aria-live = "polite" OR "assertive"
RETURN "Apply ARIA Role, States, and Properties"
END FUNCTION
Assistive Technology (AT) Ecosystem
To build accessible websites, one must understand the tools users employ to navigate them. Assistive Technology refers to any item, piece of equipment, or software that is used to increase, maintain, or improve the functional capabilities of persons with disabilities.
| AT Category | Examples | Primary Web Interaction |
|---|---|---|
| Screen Readers | NVDA, JAWS, VoiceOver | Converts text/DOM to speech or Braille. |
| Screen Magnifiers | ZoomText, Windows Magnifier | Enlarges portions of the screen; requires high-res assets. |
| Switch Access | Sip-and-puff, Single-button switches | Navigates via sequential "scanning" of interactive items. |
| Voice Recognition | Dragon NaturallySpeaking | Operates the UI via verbal commands (requires clear labels). |
The Role of Screen Readers
Screen readers do not simply read the text from top to bottom. They allow users to navigate by "landmarks" (like <nav> or <main>), headings (<h1> through <h6>), and links. This is why a logical heading hierarchy is a technical requirement, not a stylistic choice.
Web Accessibility Auditing
An Accessibility Audit is a systematic evaluation of a website's compliance with accessibility standards. A comprehensive audit must combine both Automated Testing and Manual Testing.
Automated Testing
Automated tools (like Axe-core, Lighthouse, or Pa11y) can detect approximately 30-40% of accessibility issues, such as missing alt text, low color contrast, or duplicate IDs.
# Example: Running a pa11y audit via CLI for a CI/CD pipeline
# This command checks a local development URL against WCAG 2.1 AA standards
pa11y --standard WCAG2AA --reporter cli http://localhost:3000/dashboard
Manual Testing
Manual testing is required for issues that require human judgment, such as:
- Keyboard Navigation: Can every interactive element be reached and activated using only the
TabandEnterkeys? - Focus Management: When a modal opens, does the focus move inside it? When it closes, does it return to the trigger?
- Alt Text Quality: Does the image description actually convey the intent of the image, or is it just a literal description?
- Screen Reader UX: Does the page flow make sense when heard rather than seen?
Audit Workflow Table
| Step | Method | Tooling | Objective |
|---|---|---|---|
| 1. Static Analysis | Automated | Linters (ESLint-plugin-jsx-a11y) | Catch syntax errors in code. |
| 2. Dynamic Scan | Automated | Lighthouse / Axe DevTools | Catch rendering and contrast issues. |
| 3. Keyboard Walkthrough | Manual | Keyboard Only | Ensure no "keyboard traps" exist. |
| 4. AT Simulation | Manual | VoiceOver / NVDA | Verify the "announcement" logic. |
Common Pitfalls and Edge Cases
The "Clickable Div"
A common mistake is attaching a click listener to a <div>. Because a <div> is not a focusable element, keyboard users cannot interact with it.
Fix: Use a <button> or add tabindex="0" and a keydown listener.
Over-using aria-live
The aria-live attribute tells a screen reader to announce changes to a specific area of the page. Setting it to assertive will interrupt the screen reader's current speech.
Pitfall: Using assertive for non-critical updates (like a clock ticking) creates a "noisy" and unusable experience. Use polite for most updates.
Responsive Design vs. Accessibility
Developers often hide elements on mobile using display: none.
Technical Note: display: none removes the element from the Accessibility Tree. If you want to hide an element visually but keep it for screen readers (e.g., a "Skip to Content" link), use a "visually hidden" CSS utility class.
/* The 'Visually Hidden' pattern */
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
/* Edge case: Respecting user system preferences */
@media (prefers-reduced-motion: reduce) {
* {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}
Conclusion: The Ethics of Code
Web accessibility is the technical manifestation of digital ethics. By adhering to WCAG standards and utilizing semantic HTML and ARIA correctly, developers ensure that the internet remains a universal resource. As the web evolves toward more complex interfaces (AI-driven components, 3D environments, etc.), the principles of the Accessibility Tree and the POUR framework remain the essential guideposts for inclusive engineering.

Source Materials
Study Computer Applications and Information Technology on Lykke
This course page is free to open: signed out, you can read its first two sections, and signing in, on any plan, opens the rest. The free Lykke Chrome extension syncs your own Canvas courses, so ChatGPT, Claude and Muse can answer from your classes and deadlines. It only reads Canvas.
Add the free extensionSign in to open every sectionAll sections of Computer Applications and Information Technology · Browse more course pages