Domanda

Dato il seguente html, perché ottieni l'errore:

.

Convalida (HTML5): Elemento 'TH' non può essere annidato in elemento 'Tabella'

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

È stato utile?

Soluzione

Non è possibile avere l'elemento <th> al di fuori di un <tr>, il seguente snippet è valido

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

contesto di utilizzo https://Developer.mozilla.org/en/docs/web/html/element/th

.

Elementi genitori consentiti

Un elemento <tr>.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top