html - 将 h3(或任何标题)放在 td 标签内是否有效?

标签 html html-table w3c-validation html-heading

问题是针对 TH 标签提出的,但我找不到针对 TD 标签的问题。

我可以把标题放在里面吗 <td>标签?

最佳答案

thead 不是 h3,如果你在 td 元素中使用 h3,那绝对没问题,但是如果您使用 h3 作为 tr 的直接子级是无效的。

为了使用thead,你可以像这样使用它

<table>
   <thead>
      <tr>
         <th>This is table head and not h3</th>
      </tr>
   </thead>
   <tfoot>
      <tr>
         <td>Foot Cell</td>
      </tr>
   </tfoot>
   <tbody>
       <tr>
          <td>
             <h3>It's completely valid to put your h3 here</h3>
             Table cell
             <p>You can also use p tag here
           </td>
       </tr>
   </tbody>
</table>

但是如果你这样做的话,是无效的

<罢工>

<罢工>
<table>
   <tr>
      <h3>It's invalid</h3>
      <td>This is a cell</td>
   </tr>
</table>

<罢工>

您可以随时查看here您的标记是否有效。

关于html - 将 h3(或任何标题)放在 td 标签内是否有效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19268914/

相关文章:

php - jZebra - 原始命令入门

html - 如何对齐表格单元格 (<td>) 中的元素?

css - 绑定(bind)到底部的 div 的最大高度

javascript - 在 Bootstrap 模态窗口上使用 Intro.js 提示,提示显示在模态后面

php - 基于转置的 Joomla 数据创建 html 表

html - 有效的 XHTML : "itemscope" is not a member of a group specified for any attribute

html - 具有固定布局 TABLE 和 TD 宽度百分比的 IE 7/8 错误

css - 站点基础 : min width/fixed table column

xhtml - Website W3C validator 显示 "Mismatch between Public and System identifiers in the DOCTYPE declaration",怎么办?

javascript - XHTML Mobile 1.0 - W3C 验证因脚本而无效