0
0

Warning: validateDOMNesting(...): <th> cannot appear as a child of <thead>

Posted at
Warning: validateDOMNesting(...): <th> cannot appear as a child of <thead>

というエラーがでたので解決した方法をここに綴ります。

翻訳

< th >は< thead >の子要素として使用できません。

問題のコード

html
<table>
  <thead>
    <th>タイトル1</th>
    <th>タイトル2</th>
  </thead>
  <tbody>
    <tr>
      <td>内容1</td>
      <td>内容2</td>
    </tr>
  </tbody>
</table>

解決方法

html
<table>
  <thead>
+    <tr>
      <th>タイトル1</th>
      <th>タイトル2</th>
+    </tr>
  </thead>
  <tbody>
    <tr>
      <td>内容1</td>
      <td>内容2</td>
    </tr>
  </tbody>
</table>

warningが出ているから画面が表示されないわけではないですが、するに越したことはないです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0