Online admissions open for the SEO, web development and networking & cybersecurity courses. Enquire for the next batch.

Web Accessibility: WCAG 2.2 Basics for Developers

5 min read Updated By the SkillNewton team

What is web accessibility?

Web accessibility means building websites that people with disabilities can perceive, understand, navigate and use, including people who are blind, have low vision, are deaf, have motor or cognitive disabilities, or use assistive technology such as screen readers. The Web Content Accessibility Guidelines (WCAG) 2.2, published by the W3C, define testable success criteria, and level AA is the usual target.

WCAG 2.2, conformance levels and the POUR principles

WCAG is organised into principles, guidelines and success criteria. Each criterion has a level: A (minimum), AA (the common legal and contractual target) and AAA (enhanced). Meeting AA means meeting every A and AA criterion.

PrincipleMeaningExample
PerceivableContent can be seen, heard or otherwise sensedAlt text for images, captions for video, enough colour contrast
OperableEvery function works with the input people useFull keyboard access, visible focus, no time traps
UnderstandableContent and behaviour are predictable and clearLabelled form fields, helpful error messages, declared page language
RobustAssistive technology can interpret the codeValid semantic HTML, correct names and roles for controls

WCAG 2.2 became a W3C Recommendation in October 2023. It added criteria such as Focus Not Obscured (Minimum), Dragging Movements, Target Size (Minimum) of 24 by 24 CSS pixels and Accessible Authentication, and it removed the old 4.1.1 Parsing criterion.

Semantic HTML and alternative text

Native HTML elements come with built-in roles, keyboard behaviour and names. A <button> is focusable and responds to Enter and Space; a clickable <div> does neither. Use landmarks and a logical heading order as explained in semantic HTML elements.

<html lang="en">
<header>...</header>
<nav aria-label="Main">...</nav>
<main>
  <h1>Online web development course</h1>
  <img src="chart.png" alt="Bar chart: enquiries rose each month from January to June">
  <img src="divider.svg" alt="">   <!-- decorative: empty alt -->
  <button type="button">Show syllabus</button>
</main>
<footer>...</footer>
  • Write alt text that gives the purpose or information of the image, not "image of".
  • Use alt="" for purely decorative images so screen readers skip them.
  • For a linked image, the alt text should describe the destination.
  • Every form field needs a visible <label> tied to it with for and id; see building HTML forms.

Colour contrast

At level AA, normal text needs a contrast ratio of at least 4.5:1 against its background. Large text (at least 18 point, or 14 point bold, roughly 24px or 18.66px bold) needs 3:1. Icons, input borders and focus indicators need 3:1 against adjacent colours.

For example, mid-grey text #777777 on white falls just short of 4.5:1, while #595959 on white passes comfortably. Placeholder text, disabled-looking links and text over photos are common places where contrast fails, so check every state, including hover and focus.

Colour must not be the only way to convey information: mark an invalid field with text and an icon, not just a red border. Check contrast with the colour picker in Chrome DevTools or a contrast checker while choosing your CSS palette.

Keyboard access and visible focus

Many people use a keyboard, switch device or voice control instead of a mouse. Every interactive element must be reachable with Tab, usable with Enter or Space, and in a logical order that follows the visual layout.

/* Never remove the focus outline without another visible style */
:focus-visible {
  outline: 3px solid #1a56db;
  outline-offset: 2px;
}

/* Respect users who ask for less motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none; transition: none; }
}
  • Do not use positive tabindex values; they break the natural order.
  • When a modal opens, move focus into it, keep focus inside while it is open, close it with Escape, and return focus to the button that opened it.
  • Add a "Skip to main content" link as the first focusable element.
  • Make sure sticky headers or cookie banners do not hide the focused element, as WCAG 2.2 now requires.

ARIA: when and how to use it

ARIA (Accessible Rich Internet Applications) attributes add roles, states and names that HTML alone cannot express. ARIA changes only what assistive technology announces; it adds no behaviour, so you still write the keyboard handling in JavaScript.

  1. If a native HTML element or attribute does the job, use it instead of ARIA.
  2. Do not change native semantics unless you must; avoid <h2 role="button">.
  3. All interactive ARIA controls must work with a keyboard.
  4. Do not use role="presentation" or aria-hidden="true" on a focusable element.
  5. Every interactive element needs an accessible name.
<button type="button" aria-expanded="false" aria-controls="menu">Menu</button>
<ul id="menu" hidden>...</ul>

<div role="status">Your enquiry has been sent.</div>  <!-- announced politely -->

Testing accessibility and the Indian context

Automated checkers such as Lighthouse, axe DevTools or WAVE catch problems like missing alt text, low contrast and unlabelled fields, but they find only part of the issues. Combine them with manual checks:

  • Navigate the whole page with only the keyboard.
  • Listen to it with a screen reader: NVDA (free) on Windows, VoiceOver on macOS and iOS, TalkBack on Android.
  • Zoom to 200 per cent and view at a 320px-wide viewport; content should reflow without horizontal scrolling.
  • Check headings and landmarks in the browser accessibility tree.

In India, the Rights of Persons with Disabilities Act, 2016 requires accessibility standards for information and communication technology, and government websites follow the Guidelines for Indian Government Websites (GIGW), which are based on WCAG. For private projects, WCAG 2.2 AA is a sound technical baseline; seek legal advice for specific compliance obligations.

Practical exercise: audit and fix one page

  1. Pick a page you built, unplug the mouse, and complete its main task (for example, submitting a form) using only the keyboard. Note anything you cannot reach or see.
  2. Run Lighthouse or axe and list each issue with its WCAG criterion.
  3. Fix headings so there is one h1 and no skipped levels, add alt text, and label every form field.
  4. Fix any text below 4.5:1 contrast and add a visible :focus-visible style.
  5. Test once more with NVDA or VoiceOver and confirm each control announces a sensible name and role.

You are done when the page has no automated errors, works fully by keyboard and makes sense through a screen reader. The PHP Foundation course applies these checks to the pages learners build.

Common mistakes

  • Removing focus outlines with outline: none without adding another visible focus style.
  • Using div or span elements as buttons without keyboard support or a role.
  • Relying on placeholder text instead of a visible label on form fields.
  • Adding ARIA everywhere, which often makes pages harder to use than plain semantic HTML.
  • Treating a clean automated report as proof that a page is accessible.

Frequently asked questions

Is WCAG 2.1 still valid?

Yes. WCAG 2.2 is backwards-compatible, so a page that meets 2.2 AA also meets 2.1 AA. New projects should target 2.2 because it adds criteria on focus, target size and authentication.

Do accessibility overlay widgets make a site compliant?

No. Overlays cannot fix missing labels, broken keyboard access or poor structure in the underlying code, and they can interfere with users' own assistive technology. Fix the HTML, CSS and JavaScript instead.

Does accessibility help SEO?

Several practices overlap: descriptive alt text, clear headings, meaningful link text and fast, well-structured pages help both people and search engines understand content. Accessibility is about users first, though, not rankings.

Want to Learn This Properly?

The PHP Web Development: Foundation & Practical Implementation (Online) turns guides like this into practised skills, with projects on real websites.

WhatsApp Call Us Now

Free counselling

Send an Enquiry

Tell us which course you are interested in. We reply by email or phone with the next batch and how to enrol.

Protected by reCAPTCHA. Google Privacy and Terms apply.

We reply by email or phone within working hours. No spam.