Skip to content

Empty <html> lang attributes report as fail of html-has-lang, pass for html-lang-valid #3624

@thibaudcolas

Description

@thibaudcolas

Product

axe-core

Product Version

4.4.2

Latest Version

  • I have tested the issue with the latest version of the product

Issue Description

For <html lang="">, html-has-lang fails, and html-lang-valid passes. This is a similar issue to #3623, where I would expect the rules to be consistent with one-another.

Expectation

Both rules should be consistent. If lang="" is indeed a valid lang attribute value, then html-has-lang should pass (both rules should pass). If it’s not a valid value, then either both rules should fail, or only html-lang-valid should fail.

Actual

Currently, <html lang=""> passes html-lang-valid.

How to Reproduce

Here are two sites where this happens, and Axe CLI commands:

axe -r html-has-lang,html-lang-valid https://www.koldijkbv.nl/ --save empty-lang.json
axe -r html-has-lang,html-lang-valid https://loyalty.posnania.eu/ --save empty-lang.json

In each case, see the html-has-lang violation while html-lang-valid is marked as a "pass".

Additional context

Similarly to #3623, I was also tempted to report this to Lighthouse instead / in addition to Axe, as its overly simplified audit messages make this even more confusing. It would report:

  • An error "<html> element does not have a [lang] attribute"
  • And a pass "<html> element has a valid value for its [lang] attribute"

Metadata

Metadata

Assignees

No one assigned

    Labels

    configurationrules / checks customisationprA pr has been created for the issuerulesIssue or false result from an axe-core rule

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions