我希望将 < td > 中的文本与顶部对齐

我有以下密码

<table style="height: 275px; width: 188px">
<tr>
<td style="width: 259px;">
main page
</td>
</tr>
</table>

主页出现在单元格的中央,我希望它出现在顶部。

229649 次浏览

https://developer.mozilla.org/en/CSS/vertical-align

<table style="height: 275px; width: 188px">
<tr>
<td style="width: 259px; vertical-align:top">
main page
</td>
</tr>
</table>

?

Use <td valign="top" style="width: 259px"> instead...

Add a vertical-align property to the TD, like this:

<td style="width: 259px; vertical-align: top;">
main page
</td>

you can use valign="top" on the td tag it is working perfectly for me.

I was facing such a problem, look at the picture below

enter image description here

and here is its HTML

<tr class="li1">
<td valign="top">1.</td>
<td colspan="5" valign="top">
<p>How to build e-book learning environment</p>
</td>
</tr>

so I fix it by changing valign Attribute in both td tags to baseline

and it worked

here is the result enter image description here

hope this help you