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

HtmlCss

Html Problem Overview


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.

Html Solutions


Solution 1 - Html

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>

?

Solution 2 - Html

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

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

Solution 3 - Html

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

Solution 4 - Html

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

Solution 5 - Html

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBuffonView Question on Stackoverflow
Solution 1 - HtmlthirtydotView Answer on Stackoverflow
Solution 2 - HtmlVik DavidView Answer on Stackoverflow
Solution 3 - HtmlJayView Answer on Stackoverflow
Solution 4 - HtmlBasheer AL-MOMANIView Answer on Stackoverflow
Solution 5 - HtmlFaraz Ahmad RamishView Answer on Stackoverflow