[html] 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.

This question is related to html css

The answer is


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


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