George V. Reilly

HTML5 tables require tr inside thead

When I learned HTML tables back in the 90s, at some point I discovered the element for grouping the column headers. What I missed was there should be a element between the two. In other words, a well-formed HTML table with a header looks like this:

<table>
    <thead>
        <tr>
            <th>Nameth>
            <th>Valueth>
            <th>Dateth>
        tr>
    thead>
    <tbody>
        <tr>
            <td>USERNAMEtd>
            <td>John.Smithtd>
            <td>2017-02-18T23:47td>
        tr>
    tbody>
table>

and not:

<table>
    <thead>
        <th>Nameth>
        <th>Valueth>

The latter form— directly enclosing s—had always worked for me. Until yesterday when I ran afoul of an HTML5 validator on a remote API, which simply would not let me proceed until I wrapped my cells with a .

Who knew?

blog comments powered by Disqus
Review: The Italian Job » « Review: Skinny Dip