Web Accessibility in Java

Web accessibility means designing and developing websites, applications, and digital content so they can be used by people with different abilities, devices, and assistive technologies. Accessible HTML helps remove barriers for people with visual, auditory, motor, or cognitive disabilities and improves usability for a wider audience.

To check HTML accessibility in Java, create a WebAccessibility instance, obtain an AccessibilityValidator, validate an HTMLDocument, and inspect the returned ValidationResult for rule details, errors, and warnings.

Automated validation can identify many rule-based issues, but a successful automated result alone does not establish complete WCAG conformance. Combine automated checks with keyboard testing, screen reader testing, visual review, and content review.

Articles in This Section

What Is Web Accessibility?

The Web Content Accessibility Guidelines (WCAG) organize accessibility requirements under four principles: content should be perceivable, operable, understandable, and robust. In practice, this includes semantic structure, keyboard access, text alternatives, readable contrast, understandable controls, and compatibility with assistive technologies.

Accessibility is an ongoing process rather than a one-time test. Pages should be checked as their markup, design, scripts, media, and user workflows change.

Check HTML Accessibility in Java

The com.aspose.html.accessibility package provides APIs for creating validators, selecting accessibility rules, and inspecting validation results. The following example validates a local HTML document and prints details for failed rules.

  1. Create a WebAccessibility instance.
  2. Call createValidator() to obtain an AccessibilityValidator.
  3. Load the source HTML file into an HTMLDocument.
  4. Call validator.validate(document) to run the configured checks.
  5. Inspect ValidationResult.getSuccess() and iterate through rule details when validation reports failures.
 1// Check HTML document for WCAG compliance in Java and log each rule code, description, and pass status
 2
 3// Create a WebAccessibility instance
 4WebAccessibility webAccessibility = new WebAccessibility();
 5
 6// Create an accessibility validator
 7AccessibilityValidator validator = webAccessibility.createValidator();
 8
 9// Prepare a path to a source HTML file
10String documentPath = "test-checker.html";
11
12// Initialize an HTMLDocument object
13final HTMLDocument document = new HTMLDocument(documentPath);
14ValidationResult result = validator.validate(document);
15
16// Checking for success
17if (!result.getSuccess()) {
18    for (RuleValidationResult detail : result.getDetails()) {
19        // ... do the analysis here...
20        System.out.println(String.format("%s: %s = %s",
21                detail.getRule().getCode(),
22                detail.getRule().getDescription(),
23                detail.getSuccess()
24        ));
25    }
26}

Why Web Accessibility Matters

The Web is an essential resource for education, employment, health care, commerce, public services, recreation, and communication. Accessibility helps provide equal access and opportunity to people who use screen readers, captions, keyboard navigation, magnification, voice input, or other assistive technologies.

Accessibility is important for several reasons:

Accessibility and SEO

Accessibility and SEO overlap where both benefit from clear, machine-readable content. Semantic HTML, meaningful headings, descriptive links, useful image alt text, captions, transcripts, and predictable navigation help users and automated systems understand a page.

This does not mean that every accessibility requirement is a direct search ranking factor. The practical benefit is that accessible content is generally easier to crawl, interpret, navigate, and reuse.

Web Accessibility Standards

The main international reference is WCAG. WCAG defines testable success criteria at conformance levels A, AA, and AAA. W3C recommends using the latest applicable WCAG version when developing or updating accessibility policies, while a law, contract, or organizational policy may require a specific version and level.

Other relevant standards and policy frameworks include:

The Aspose.HTML for Java accessibility API provides rules based on WCAG 2.0. It evaluates a document against the selected AccessibilityRules; the result should not be treated as a legal certification or as complete validation against newer WCAG versions.

FAQ

Can Aspose.HTML for Java automatically make a website accessible?

No. Aspose.HTML for Java can validate HTML and report accessibility issues. Fixing them usually requires changes to markup, content, design, keyboard interaction, and media alternatives.

Can automated accessibility checks replace manual testing?

No. Automated checks can detect many rule-based issues, but reliable evaluation also requires manual review, keyboard testing, assistive technology testing, and review by people familiar with the content and user flows.

Which WCAG version does Aspose.HTML for Java support?

Aspose.HTML for Java provides accessibility rules based on WCAG 2.0 requirements, success criteria, and techniques. If a project targets WCAG 2.1 or WCAG 2.2, use the Aspose.HTML results as part of the assessment and supplement them with checks for criteria introduced in those newer versions.

Related Resources

Other Platforms

Try Web Accessibility Checker

Try the free online Web Accessibility Checker to scan a web page, identify WCAG-related issues, and estimate the scope of accessibility improvements before implementing fixes in Java.

Text “Web Accessibility Checker”