Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-5257

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

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Replace this layout table with a CSS layout.
    • Highlighting:
      Hide

      The opening <table> element, without its content.

      Show
      The opening <table> element, without its content.
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Targeted languages:
      HTML
    • Irrelevant for Languages:
      ABAP, APEX, C#, C, C++, Cobol, CSS, Flex, Go, Java, JavaScript, Kotlin, Objective-C, PHP, PL/I, PL/SQL, Python, RPG, Ruby, Rust, Scala, Solidity, Swift, T-SQL, TypeScript, VB.Net, VB6, XML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      30min
    • Analysis Scope:
      Main Sources, Test Sources

      Description

      HTML <table> elements should not be used for layout purpose as it can confuse screen readers. It is recommended to use CSS instead.

      This rule raises an issue on every <table> element containing a role attribute set to "presentation" or "none", which is how W3C recommends marks layout tables.

      Noncompliant Code Example

      <table role="presentation">
      <!-- ... -->
      </table>
      

      See

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              nicolas.harraudeau Nicolas Harraudeau (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: