< td>的宽度当我使用< br>< br>时,在一个固定的宽度< table>上。为什么?

< td>的宽度当我使用< br>< br>时,在一个固定的宽度< table>上。为什么?

问题描述:

我有这段HT​​ML代码片段(在使用严格doctype的有效文档中):

I have this HTML code fragment (in a valid document using strict doctype):

<p>Without &lt;br /&gt;</p>
<table border="1" width="220">
<tbody>
    <tr>
        <td>lorem</td>
        <td>ipsum</td>
        <td>lorem ipsum</td>
        <td>lorem</td>
        <td>ipsum</td>
    </tr>
</tbody>
</table>

<p>With &lt;br /&gt;</p>
<table border="1" width="220">
<tbody>
    <tr>
        <td>lorem</td>
        <td>ipsum</td>
        <td>lorem<br>ipsum</td>
        <td>lorem</td>
        <td>ipsum</td>
    </tr>
</tbody>
</table>

这在任何浏览器中都是这样呈现的:

This is rendered like this in any browser:

请注意,第三&LT; TD&GT;在第一个表格中更宽,这是因为我没有使用< br>在那里标记。否则这两个表的代码是相同的。

Please note that the third <td> is wider in the first table, only because I haven't used a <br> tag there. Otherwise the code for the two tables are identical.

我想找到一种方法让表格像第二个例子那样呈现,但不必使用a< br>标记。

I would like to find a way to have the table rendered like it is on the second example, but without having to use a <br> tag.

我无法指定单元格的宽度,因为它们可能包含任何数量的字符。

看起来像这是一个古老的问题/问题 - 很遗憾,我没有解决方案从2005年开始提供这个链接,证明有人在这个时候就已经在挣扎了。 :)

Seems like this is an ages old problem / question - unfortunately I have no solution to offer just this link from 2005 which proves that someone was struggling with this already even back then. :)

http://www.velocityreviews.com/forums/t162343-how-to-prevent-unnecessary-table-resizing.html