简体   繁体   中英

I want to align the text in a <td> to the top

I have the following code

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

The main page appears in the center of the cell I want it to appear at the top.

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>

?

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

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

使用<td valign="top" style="width: 259px">代替......

你可以在td标签上使用valign="top" ,它对我来说非常合适。

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

在此输入图像描述

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 在此输入图像描述

hope this help you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM