Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

html

css

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.

like image 971
Buffon Avatar asked Apr 15 '11 02:04

Buffon


People also ask

How do I align text in TD top?

To place an item at the top or bottom of its cell, insert the "VALIGN=" attribute within the code for that cell. To vertically align an entire row (e.g., placing all data in that row at the tops of the cells), insert the "VALIGN=" attribute within the code for that row.

How do I put text on top of a table in HTML?

The <caption> tag defines a table caption. The <caption> tag must be inserted immediately after the <table> tag. Tip: By default, a table caption will be center-aligned above a table. However, the CSS properties text-align and caption-side can be used to align and place the caption.


2 Answers

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> 

?

like image 148
thirtydot Avatar answered Nov 16 '22 01:11

thirtydot


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

<td style="width: 259px; vertical-align: top;"> main page </td> 
like image 23
Vik David Avatar answered Nov 16 '22 00:11

Vik David