为什么 <th> 标签内的 <br> 后需要有文字?
Why there needs to be text after a <br> inside the <th> tag?
这是一个关于 <br>
标签在另一个标签内时的行为的问题。
我正在做这个 table,其中有一个 <thead>
,里面有两个 <th>
:一个读作 "name"和另一个"last name"。在'last'和'name'之间插入一个<br>
,显示第二个<th>
两条线并避免更长的单元格宽度。
现在 "last name" 显示为两行,<th>
中的文本不会以相同的高度开始。
我希望 "name" <th>
中的文本与 "last name" 中的文本起始高度相同 <th>
.
- 键入
<th>NAME <br> </th>
没有任何作用。
- 键入
<th>NAME <br> .</th>
会出现所需的换行符。
为什么会这样?
标签之间的空格是否应该算作内容,从而激活 <br>
优点?
如何在 "name" <th>
中实现两行,而第二行没有不必要的字符,或者不必使用 [=82 设置样式=]?
检查html并赐教
<html>
<body>
<table border="2px">
<thead>
<th>NAME <br> </th>
<th>LAST<br>NAME</th>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</tbody>
</table>
<br>
<table border="2px">
<thead>
<th>NAME <br> .</th>
<th>LAST<br>NAME</th>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</tbody>
</table>
</body>
</html>
我很好奇 <br>
在另一个标签内时的错误行为。
您可以尝试在它们之间放置一个
来满足您的需求。
<th>NAME <br> </th>
或者您可以关闭 br 标签,这样应该可以
<th>NAME <br /> </th>
使用 style="vertical-align:top;"
或 valign="top"
使其顶部对齐
<html>
<body>
<table border="2px">
<thead>
<th valign="top">NAME</th>
<th>LAST<br>NAME</th>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</tbody>
</table>
<br>
<table border="2px">
<thead>
<th style="vertical-align:top;">NAME</th>
<th>LAST<br>NAME</th>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</tbody>
</table>
</body>
</html>
这是一个关于 <br>
标签在另一个标签内时的行为的问题。
我正在做这个 table,其中有一个 <thead>
,里面有两个 <th>
:一个读作 "name"和另一个"last name"。在'last'和'name'之间插入一个<br>
,显示第二个<th>
两条线并避免更长的单元格宽度。
现在 "last name" 显示为两行,<th>
中的文本不会以相同的高度开始。
我希望 "name" <th>
中的文本与 "last name" 中的文本起始高度相同 <th>
.
- 键入
<th>NAME <br> </th>
没有任何作用。 - 键入
<th>NAME <br> .</th>
会出现所需的换行符。
为什么会这样?
标签之间的空格是否应该算作内容,从而激活 <br>
优点?
如何在 "name" <th>
中实现两行,而第二行没有不必要的字符,或者不必使用 [=82 设置样式=]?
检查html并赐教
<html>
<body>
<table border="2px">
<thead>
<th>NAME <br> </th>
<th>LAST<br>NAME</th>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</tbody>
</table>
<br>
<table border="2px">
<thead>
<th>NAME <br> .</th>
<th>LAST<br>NAME</th>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</tbody>
</table>
</body>
</html>
我很好奇 <br>
在另一个标签内时的错误行为。
您可以尝试在它们之间放置一个
来满足您的需求。
<th>NAME <br> </th>
或者您可以关闭 br 标签,这样应该可以
<th>NAME <br /> </th>
使用 style="vertical-align:top;"
或 valign="top"
使其顶部对齐
<html>
<body>
<table border="2px">
<thead>
<th valign="top">NAME</th>
<th>LAST<br>NAME</th>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</tbody>
</table>
<br>
<table border="2px">
<thead>
<th style="vertical-align:top;">NAME</th>
<th>LAST<br>NAME</th>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</tbody>
</table>
</body>
</html>