Skip to main content

HTML Guide

The “summary” attribute on the “table” element is obsolete. Consider describing the structure of the “table” in a “caption” element or in a “figure” element containing the “table”; or, simplify the structure of the “table” so that no description is needed.

To resolve the W3C Validator issue regarding the obsolete summary attribute on the table element, you should remove the summary attribute and instead provide a description of the table structure using a caption element.

Here’s how you can fix it:

  • Remove the summary attribute: This attribute is no longer supported in modern HTML standards.
  • Add a caption element: This element gives a brief description of the table, making it accessible and informing users what the table represents.

Example Before and After

Before Fixing (with obsolete summary attribute)

<table summary="This table shows the sales data for the year.">
    <tr>
        <th>Month</th>
        <th>Sales</th>
    </tr>
    <tr>
        <td>January</td>
        <td>$1000</td>
    </tr>
    <tr>
        <td>February</td>
        <td>$1200</td>
    </tr>
</table>

After Fixing (with caption element)

<table>
    <caption>Sales Data for the Year</caption>
    <tr>
        <th>Month</th>
        <th>Sales</th>
    </tr>
    <tr>
        <td>January</td>
        <td>$1000</td>
    </tr>
    <tr>
        <td>February</td>
        <td>$1200</td>
    </tr>
</table>

Additional Option: Using a figure Element

If you want to provide a more extensive description alongside your table, you can wrap the table in a figure element.

Example with figure

<figure>
    <figcaption>Sales Data for the Year</figcaption>
    <table>
        <tr>
            <th>Month</th>
            <th>Sales</th>
        </tr>
        <tr>
            <td>January</td>
            <td>$1000</td>
        </tr>
        <tr>
            <td>February</td>
            <td>$1200</td>
        </tr>
    </table>
</figure>

Learn more:

Related W3C validator issues