5/7 Table Headings Readability


#1

In the lesson's code, the heading code is placed outside of the table body code, like so:

 <thead>
               <tr>
                    <th>Famous Monster</th>
                    <th>Birth Year</th>
               </tr> 
 </thead>

Is there a reason why you wouldn't wrap all of the table headings in the table body code? Like so:

  <tbody>
                <thead>
                <tr>
                    <th>Famous Monster</th>
                    <th>Birth Year</th>
               </tr> 
                </thead>
                <tr>
                    <td>King Kong</td>
                    <td>1933</td>     
                </tr>
                
                <tr>
                    <td>Dracula</td>
                    <td>1897</td>
                </tr>
                
                <tr>
                    <td>Bride of Frankenstein</td>
                    <td>1935</td>
                </tr>
            </tbody>

When I enter it the second way, it works out just fine and the table looks fine. Is there a reason the lesson codes like this? Wouldn't it be better if the headings were placed within the body simply for better readability?


#2

The browser is catching your mistake, it would be better (for the underlying software) you wrote your table head first, and then your table body. This might give issues is some browser because it is not designed to function this way


#3

Would it be safe to say that most browsers will be designed to read the table head outside the table body?


#4

yea, that is safe to say, this is how it should be:

<table>
  <thead></thead>
  <tbody></tbody>
</table>