HTML: RSPEC-5254 requires lang on the html element

Based on RSPEC-5254, SonarLInt claims that the following code is non-compliant:

<!DOCTYPE html>
    <title lang="en">SonarLint Test File</title>
  <body lang="en">

The error message provided by SonarLint only goes away if

  • the html element is given a lang attribute, or
  • the html start tag is removed (since that tag is optional, even though I don’t know whether the Sonar developers are aware of this).

Note that if a lang attribute is present on the body, screen readers will pronounce the page content in that language, regardless of whether the html start tag has a different lang attribute value or no lang attribute at all.

(Even though I am using SonarLint in VS Code, I assume this issue applies to all Sonar products that implement this rule.)

Hi Christophe,

Sorry for the huge delay. I think you are right, Sonar should be able to understand this case.

I created a ticket for improving the rule:

Kind regards,