Skip to main content

The HTML Inspector scans a page for common accessibility and markup issues. It is a fast static check that can catch missing attributes, invalid references, and structural problems before they reach production.

Info

What you will learn

  • How to run an inspection.
  • Which checks are performed.
  • How to use the inspector in CI.
  • The scope and limitations of static analysis.

Run an inspection#

BaseCase::inspect_html takes the current page source and inspects it:

BaseCase::assert_no_html_issues does the same and fails with an AssertionFailed error that lists every [rule] message.

Checks performed#

Every finding has a stable rule ID and a severity. is_clean() is true only when there are no findings at all, warnings included; has_errors() is true when at least one finding has InspectionSeverity::Error.

Rule IDSeverityWhat it flags
document-langerrorThe html element has no non-empty lang.
document-titleerrorThe document has no non-empty title.
meta-viewportwarningNo viewport meta tag whose content contains width=device-width.
skip-linkwarningNo link to #maincontent or #content.
image-alterrorAn img without an alt attribute (use alt="" for decoration).
interactive-nameerrorA link (a[href]) or button without a static accessible name (text, aria-label, title, alt, or a valid aria-labelledby).
link-textwarningA link with no visible text, or with generic text: “click here”, “here”, “read more”, “more”, “link” or “details”.
nested-interactiveerrorA button inside a link.
form-control-labelerrorA form control without a label, wrapping label, aria-label, or valid aria-labelledby reference.
radio-group-legendwarningA named radio group of two or more not inside a fieldset with a legend.
duplicate-iderrorAn ID used more than once.
invalid-aria-referenceerroraria-labelledby or aria-describedby naming an ID that does not exist.
empty-headingwarningA heading with no text.
heading-orderwarningA heading level that jumps by more than one.
page-h1warningNo h1, or more than one.
table-headerswarningA table with no th cell.
main-landmarkwarningNo main element or role="main".

Access results#

selector is an Option<String>: a best-effort selector for the element, or None for document-level findings.

Use in CI#

Fail a build when new markup issues appear:

Tip

To fail only on errors and let warnings through, test inspection.has_errors() instead.

Why it matters#

Clean HTML improves accessibility, SEO, and test reliability.

Scope and limitations#

The inspector uses an HTML5 parser and deterministic static rules. Stable rule IDs and best-effort element selectors make findings suitable for CI allowlists. It does not execute JavaScript, compute styles or contrast, test keyboard behavior, or inspect the browser accessibility tree.

Warning

Use it as an early check alongside browser-based accessibility testing such as axe-core and manual keyboard and assistive-technology review. A clean result is not a claim of WCAG conformance.