Accessibility Rules in HTML Linters
You'll learn how to configure HTML linters to automatically catch accessibility violations before they reach production.
The Core Idea
Accessibility rules in HTML linters act like automated accessibility auditors. While basic HTML validation catches syntax errors, accessibility-focused rules check whether your markup can be properly used by assistive technologies like screen readers. Think of them as guardrails that prevent you from publishing inaccessible content—they enforce best practices like requiring alt text on images, ensuring proper ARIA attributes, and maintaining logical heading hierarchies.
What These Rules Check
Alt Attributes: Rules ensure every <img> has an alt attribute. Even decorative images need alt="" to signal they should be ignored by screen readers.
ARIA Validity: Linters verify that role attributes are valid and that ARIA attributes like aria-label or aria-labelledby are used correctly and only on elements that support them.
Heading Hierarchy: Rules enforce that headings follow a logical order (don't skip from <h1> to <h4>), ensuring screen reader users can navigate your document structure.
Form Labels: Every <input> should have an associated <label>, either through wrapping or the for/id relationship.
Link Text: Rules flag generic link text like "click here" and ensure links have descriptive content.
Configuration Example
In HTMLHint, you'd enable rules like:
{
"alt-require": true,
"attr-no-unnecessary-whitespace": true,
"title-require": true
}
These automated checks catch issues during development, long before manual accessibility audits.
Key Takeaway: Accessibility rules in HTML linters automatically enforce requirements like alt attributes, valid ARIA usage, and proper heading structure, catching accessibility issues early in your development workflow.