Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align the table cells content on the top?

Tags:

html

css

I have a HTML table. Each cell has content of different length.

For this reason, the content is not aligned on the top.

I would like the first lines be aligned also in cells with few lines of text (the content should always start from the top).

Instead the content is vertically centered in the middle.

How can I fix this (a cross-browser solution.. working in I.E. as well)

Thanks

like image 449
aneuryzm Avatar asked Aug 25 '10 12:08

aneuryzm


People also ask

How do I align table and cell contents?

To center align text in table cells, use the CSS property text-align. The <table> tag align attribute was used before, but HTML5 deprecated the attribute. Do not use it. So, use CSS to align text in table cells.

How do you align cells in a table in Word?

Select the text and go to the Layout tab and the Alignment section of the ribbon. Choose “Align Center.” Your text will then be right in the middle of the cell. Centering the text in your Word table is a simple task whether horizontally, vertically, or both.


1 Answers

in css

td, th {
vertical-align:top;
}
like image 177
Tim Avatar answered Oct 22 '22 23:10

Tim