Validation (HTML5): The element 'th' cannot be nested in the element table 'table'

Given the following HTML code, why are you getting the error message:

Validation (HTML5): The 'th' element cannot be nested in an element table

<table> <th>ID</th> <th>text header</th> <tr> <td>7</td> <td>text</td> </tr> </table> 
+6
source share
1 answer

You cannot have a <th> element outside of <tr> , let's say the following snippet

 <table> <tr> <th>ID</th> <th>text header</th> </tr> <tr> <td>7</td> <td>text</td> </tr> </table> 

<th> Context of use https://developer.mozilla.org/en/docs/Web/HTML/Element/th

Allowed Parent Elements

A <tr> .

+20
source

Source: https://habr.com/ru/post/970275/


All Articles