SonarSource Rules
  • Products

    In-IDE

    Code Quality and Security in your IDE with SonarQube Ide

    IDE extension that lets you fix coding issues before they exist!

    Discover SonarQube for IDE

    SaaS

    Code Quality and Security in the cloud with SonarQube Cloud

    Setup is effortless and analysis is automatic for most languages

    Discover SonarQube Cloud

    Self-Hosted

    Code Quality and Security Self-Hosted with SonarQube Server

    Fast, accurate analysis; enterprise scalability

    Discover SonarQube Server
  • SecretsSecrets
  • ABAPABAP
  • AnsibleAnsible
  • ApexApex
  • AzureResourceManagerAzureResourceManager
  • CC
  • C#C#
  • C++C++
  • CloudFormationCloudFormation
  • COBOLCOBOL
  • CSSCSS
  • DartDart
  • DockerDocker
  • FlexFlex
  • GitHub ActionsGitHub Actions
  • GoGo
  • HTMLHTML
  • JavaJava
  • JavaScriptJavaScript
  • JSONJSON
  • JCLJCL
  • KotlinKotlin
  • KubernetesKubernetes
  • Objective CObjective C
  • PHPPHP
  • PL/IPL/I
  • PL/SQLPL/SQL
  • PythonPython
  • RPGRPG
  • RubyRuby
  • RustRust
  • ScalaScala
  • ShellShell
  • SwiftSwift
  • TerraformTerraform
  • TextText
  • TypeScriptTypeScript
  • T-SQLT-SQL
  • VB.NETVB.NET
  • VB6VB6
  • XMLXML
  • YAMLYAML
HTML

HTML static code analysis

Unique rules to find Bugs, Security Hotspots, and Code Smells in your HTML code

  • All rules 83
  • Bug23
  • Security Hotspot3
  • Code Smell57
Filtered: 10 rules found
wcag2-a
    Impact
      Clean code attribute
        1. "<object>" tags should provide an alternative content

           Code Smell
        2. Table cells should reference their headers

           Bug
        3. Tables used for layout should not include semantic markup

           Bug
        4. Tables should have headers

           Bug
        5. "aria-label" or "aria-labelledby" attributes should be used to differentiate similar elements

           Code Smell
        6. "<html>" element should have a language attribute

           Bug
        7. "<th>" tags should have "id" or "scope" attributes

           Bug
        8. "input", "select" and "textarea" tags should be labeled

           Bug
        9. "<table>" tags should have a description

           Bug
        10. Image, area and button with image elements should have an "alt" attribute

           Code Smell

        "<table>" tags should have a description

        Bug
        • accessibility
        • wcag2-a

        Why is this an issue?

        More Info

        In order to be accessible to visually impaired users, it is important that tables provides a description of its content before the data is accessed.

        The simplest way to do it, and also the one recommended by WCAG2 is to add a <caption> element inside the <table>.

        Other technics this rule accepts are:

        • adding a concise description via aria-label or aria-labelledby attributes in the <table>.
        • referencing a description element with an aria-describedby attribute in the <table>.
        • embedding the <table> inside a <figure> which also contains a <figcaption>.
        • adding a summary attribute to the <table> tag. However note that this attribute has been deprecated in HTML5.

        See W3C WAI Web Accessibility Tutorials for more information.

        This rule raises an issue when a <table> has neither of the previously mentioned description mechanisms.

        Noncompliant code example

        <table> <!-- Noncompliant -->
          ...
        <table>
        

        Compliant solution

        Adding a <caption> element.

        <table>
          <caption>New York City Marathon Results 2013</caption>
          ...
        </table>
        

        Adding an aria-describedby attribute.

        <p id="mydesc">New York City Marathon Results 2013</p>
        <table aria-describedby="mydesc">
          ...
        </table>
        

        Embedding the table in a <figure> which also contains a <figcaption>.

        <figure>
          <figcaption>New York City Marathon Results 2013</figcaption>
          <table>
            ...
          </table>
        </figure>
        

        Adding a summary attribute. However note that this attribute has been deprecated in HTML5.

        <table summary="New York City Marathon Results 2013">
          ...
        </table>
        

        Exceptions

        No issue will be raised on <table> used for layout purpose, i.e. when it contains a role attribute set to "presentation" or "none". Note that using <table> for layout purpose is a bad practice.

        No issue will be raised either on <table> containing an aria-hidden attribute set to "true".

          Available In:
        • SonarQube IdeCatch issues on the fly,
          in your IDE
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories
        • SonarQube Community BuildAnalyze code in your
          on-premise CI
          Available Since
          9.1
        • SonarQube ServerAnalyze code in your
          on-premise CI
          Developer Edition
          Available Since
          9.1

        © 2008-2025 SonarSource SA. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use