<td> 标签是 HTML5 中用于定义表格中的单元格(table data cell)的元素。在表格中,每个 <td> 元素通常包含表格的一个数据单元格,即表格中的一个格子,可以包含文本、图像、链接或其他内容。

以下是 <td> 标签的基本用法:
<table border="1">
  <tr>
    <td>Row 1, Cell 1</td>
    <td>Row 1, Cell 2</td>
  </tr>
  <tr>
    <td>Row 2, Cell 1</td>
    <td>Row 2, Cell 2</td>
  </tr>
</table>

在这个例子中,<table> 元素定义了一个表格,包含两行和两列。每个 <td> 元素表示一个表格单元格,包含相应的文本内容。表格的外观通过 border="1" 属性添加了边框。

<td> 元素通常与 <tr>(表格行)和 <th>(表头单元格)等元素一起使用,以创建完整的表格结构。
<table border="1">
  <tr>
    <th>Header 1</th>
    <th>Header 2</th>
  </tr>
  <tr>
    <td>Row 1, Cell 1</td>
    <td>Row 1, Cell 2</td>
  </tr>
  <tr>
    <td>Row 2, Cell 1</td>
    <td>Row 2, Cell 2</td>
  </tr>
</table>

在这个例子中,<th> 元素用于定义表头单元格,而 <td> 元素用于定义数据单元格。表头单元格通常用于表示列的标题,而数据单元格包含实际的数据。


转载请注明出处:http://www.pingtaimeng.com/article/detail/3775/HTML5