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
 
Tags
    Impact
      Clean code attribute
        1. Label elements should have a text label and an associated control

           Code Smell
        2. Elements with an interactive role should support focus

           Code Smell
        3. Images should have a non-redundant alternate description

           Code Smell
        4. Heading elements should have accessible content

           Code Smell
        5. Non-interactive DOM elements should not have an interactive handler

           Code Smell
        6. Non-interactive elements shouldn't have event handlers

           Code Smell
        7. DOM elements should not use the "accesskey" property

           Code Smell
        8. Non-interactive DOM elements should not have the `tabIndex` property

           Code Smell
        9. Anchor tags should not be used as buttons

           Code Smell
        10. Interactive DOM elements should not have non-interactive ARIA roles

           Code Smell
        11. Non-interactive DOM elements should not have interactive ARIA roles

           Code Smell
        12. "tabIndex" values should be 0 or -1

           Code Smell
        13. DOM elements should use the "autocomplete" attribute correctly

           Code Smell
        14. Anchors should contain accessible content

           Code Smell
        15. Focusable elements should not have "aria-hidden" attribute

           Code Smell
        16. DOM elements with the `aria-activedescendant` property should be accessible via the tab key

           Code Smell
        17. ARIA properties in DOM elements should have valid values

           Code Smell
        18. Using remote artifacts without integrity checks is security-sensitive

           Security Hotspot
        19. "<object>" tags should provide an alternative content

           Code Smell
        20. Table cells should reference their headers

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

           Bug
        22. HTML "<table>" should not be used for layout purposes

           Code Smell
        23. Tables should have headers

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

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

           Bug
        26. Disabling auto-escaping in template engines is security-sensitive

           Security Hotspot
        27. Authorizing an opened window to access back to the originating window is security-sensitive

           Security Hotspot
        28. <script>...</script> elements should not be nested

           Bug
        29. Videos should have subtitles

           Code Smell
        30. Track presence of forbidden parent element

           Code Smell
        31. Dynamic includes should not be used

           Code Smell
        32. Track uses of disallowed elements

           Code Smell
        33. The "style" attribute should not be used

           Code Smell
        34. Track uses of disallowed attributes

           Code Smell
        35. Track lack of required child elements

           Code Smell
        36. Some Java packages or classes should not be used in JSP files

           Code Smell
        37. Track uses of disallowed child elements

           Code Smell
        38. Multiple "page" directives should not be used

           Code Smell
        39. White space should be used in JSP/JSF tags

           Code Smell
        40. Disallowed "taglibs" should not be used

           Code Smell
        41. Track lack of required attributes

           Code Smell
        42. Labels should be defined in the resource bundle

           Bug
        43. Track lack of required parent elements

           Code Smell
        44. Files should not be too complex

           Code Smell
        45. HTML comments should be removed

           Code Smell
        46. Web pages should not contain absolute URIs

           Code Smell
        47. Attributes deprecated in HTML5 should not be used

           Code Smell
        48. JSP expressions should not be used

           Code Smell
        49. All HTML tags should be closed

           Bug
        50. Attributes should be quoted using double quotes rather than single ones

           Code Smell
        51. JavaScript scriptlets should not have too many lines of code

           Code Smell
        52. Track lack of copyright and license headers

           Code Smell
        53. Track lack of required an element with the required "id"

           Code Smell
        54. JSF expressions should be syntactically valid

           Bug
        55. Track uses of disallowed namespaces in XHTML documents

           Code Smell
        56. Sections of code should not be commented out

           Code Smell
        57. Track uses of "TODO" tags

           Code Smell
        58. Track uses of "FIXME" tags

           Code Smell
        59. "<th>" tags should have "id" or "scope" attributes

           Bug
        60. Links with identical texts should have identical targets

           Code Smell
        61. "<strong>" and "<em>" tags should be used

           Bug
        62. Image tags should have "width" and "height" attributes

           Bug
        63. Favicons should be used in all pages

           Code Smell
        64. "input", "select" and "textarea" tags should be labeled

           Bug
        65. "<title>" should be present in all pages

           Bug
        66. "<!DOCTYPE>" declarations should appear before "<html>" tags

           Bug
        67. Meta tags should not be used to refresh or redirect

           Code Smell
        68. "<li>" and "<dt>" item tags should be in "<ul>", "<ol>" or "<dl>" container tags

           Bug
        69. Links should not directly target images

           Code Smell
        70. Server-side image maps ("ismap" attribute) should not be used

           Bug
        71. "<frames>" should have a "title" attribute

           Bug
        72. "<fieldset>" tags should contain a "<legend>"

           Bug
        73. Flash animations should be embedded using the window mode

           Bug
        74. Flash animations should be embedded using both "<object>" and "<embed>"

           Bug
        75. Heading tags should be used consecutively from "H1" to "H6"

           Code Smell
        76. "<table>" tags should have a description

           Bug
        77. Links should not target "#" or "javascript:void(0)"

           Code Smell
        78. Elements deprecated in HTML5 should not be used

           Bug
        79. Mouse events should have corresponding keyboard events

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

           Code Smell
        81. Tabulation characters should not be used

           Code Smell
        82. Files should not have too many lines

           Code Smell
        83. Lines should not be too long

           Code Smell

        All HTML tags should be closed

        intentionality - complete
        reliability
        Bug

          Why is this an issue?

          Even if all browsers are fault-tolerant, HTML tags should be closed to prevent any unexpected behavior.

          Noncompliant code example

          <html>
            <head>
              <title>Test Page    <!-- Noncompliant; title not closed -->
            <!-- Noncompliant; head not closed -->
            <body>
              <em>Emphasized Text  <!-- Noncompliant; em not closed -->
            <!-- Noncompliant; body not closed -->
          </html>
          

          Compliant solution

          <html>
            <head>
              <title>Test Page</title>
            </head>
            <body>
              <em>Emphasized Text</em>
            </body>
          </html>
          
            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