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. "<object>" tags should provide an alternative content

           Code Smell
        19. HTML "<table>" should not be used for layout purposes

           Code Smell
        20. "aria-label" or "aria-labelledby" attributes should be used to differentiate similar elements

           Code Smell
        21. Videos should have subtitles

           Code Smell
        22. Track presence of forbidden parent element

           Code Smell
        23. Dynamic includes should not be used

           Code Smell
        24. Track uses of disallowed elements

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

           Code Smell
        26. Track uses of disallowed attributes

           Code Smell
        27. Track lack of required child elements

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

           Code Smell
        29. Track uses of disallowed child elements

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

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

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

           Code Smell
        33. Track lack of required attributes

           Code Smell
        34. Track lack of required parent elements

           Code Smell
        35. Files should not be too complex

           Code Smell
        36. HTML comments should be removed

           Code Smell
        37. Web pages should not contain absolute URIs

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

           Code Smell
        39. JSP expressions should not be used

           Code Smell
        40. Attributes should be quoted using double quotes rather than single ones

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

           Code Smell
        42. Track lack of copyright and license headers

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

           Code Smell
        44. Track uses of disallowed namespaces in XHTML documents

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

           Code Smell
        46. Track uses of "TODO" tags

           Code Smell
        47. Track uses of "FIXME" tags

           Code Smell
        48. Links with identical texts should have identical targets

           Code Smell
        49. Favicons should be used in all pages

           Code Smell
        50. Meta tags should not be used to refresh or redirect

           Code Smell
        51. Links should not directly target images

           Code Smell
        52. Heading tags should be used consecutively from "H1" to "H6"

           Code Smell
        53. Links should not target "#" or "javascript:void(0)"

           Code Smell
        54. Image, area and button with image elements should have an "alt" attribute

           Code Smell
        55. Tabulation characters should not be used

           Code Smell
        56. Files should not have too many lines

           Code Smell
        57. Lines should not be too long

           Code Smell

        Label elements should have a text label and an associated control

        intentionality - logical
        reliability
        Code Smell
        • accessibility

        A <label> element should wrap a control element or have an <htmlFor> attribute referencing a control and text content.

        Why is this an issue?

        How can I fix it?

        More Info

        When a label element lacks a text label or an associated control, it can lead to several issues:

        1. Poor Accessibility: Screen readers rely on correctly associated labels to describe the function of the form control. If the label is not properly associated with a control, it can make the form difficult or impossible for visually impaired users to understand or interact with.
        2. Confusing User Interface: Labels provide users with clear instructions about what information is required in a form control. Without a properly associated label, users might not understand what input is expected, leading to confusion and potential misuse of the form.
        3. Code Maintainability: Properly structured and labeled code is easier to read, understand, and maintain. When labels are not correctly associated, it can make the code more difficult to navigate and debug, especially for new developers or those unfamiliar with the codebase.

        Control elements are: * <input> * <meter> * <output> * <progress> * <select> * <textarea>

        Exceptions

        Custom components may contain control elements, therefore label elements containing custom elements do not raise issues.

          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
          10.5
        • SonarQube ServerAnalyze code in your
          on-premise CI
          Developer Edition
          Available Since
          10.5

        © 2008-2025 SonarSource SA. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use