换行符出现在表格上方,而不是我通常所期望的那样。我只是想知道为什么会这样。
<table>
<tr>
<th>cell group 1</th><!--<br> this wouldnt work-->
<td>cell 1</td>
<td>cell 2</td>
<td>cell 3</td>
<td>cell 4</td>
</tr>
<tr>
<th>cell group 2</th>
<td>cell 5</td>
<td>cell 5</td>
<td>cell 6</td>
<td>cell 7</td>
</tr>
<tr>
<th>cell group 3</th>
<td>cell 8</td>
<td>cell 9</td>
<td>cell 10</td>
<td>cell 11</td>
</tr>
</table>
答案 0 :(得分:2)
您不能在表结构中放置<br>
标记。但您可以在单元格元素中执行此操作:<th>
或<td>
。
示例:
<table>
<tr>
<th>cell group 1<br></th>
<td>cell 1</td>
<td>cell 2<br></td>
<td>cell 3</td>
<td>cell 4</td>
</tr>
<tr>
<th>cell group 2</th>
<td>cell 5</td>
<td>cell 5</td>
<td>cell 6</td>
<td>cell 7</td>
</tr>
<tr>
<th>cell group 3</th>
<td>cell 8</td>
<td>cell 9</td>
<td>cell 10</td>
<td>cell 11</td>
</tr>
</table>
答案 1 :(得分:0)
表格的可视内容只能存在于表格数据单元格标签(td
或th
)中 - 将元素放在它们之间没有逻辑意义 - 它会出现在哪里?
如果您有一些表格数据,并希望在两个数据单元格之间添加,那么它只会成为另一个数据单元格,并不是它。
如果你想调整表格某些部分的视觉外观,应该用CSS边距或填充样式来完成,而不是通过添加换行符(这一般适用 - br
不应该用于调整元素的大小。)