Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to top, left justify text in a <td> cell that spans multiple rows

Tags:

html

css

I have the following html code:

<table border="1">   <tr>     <th>Month</th>     <th>Savings</th>   </tr>   <tr>     <td>January</td>     <td>$100</td>   </tr>   <tr>     <td>February</td>     <td rowspan="2">Save a lot</td>   </tr>   <tr>     <td>March</td>   </tr> </table> 

Using CSS styling or another method, can I make the text "Save a lot" top, left justified?

like image 344
Kevin Le - Khnle Avatar asked Jun 17 '11 16:06

Kevin Le - Khnle


People also ask

How do I align text in the top of the span?

you just need to specify the height of the span , the same with the td element that contain it, set the width:100% so there won't be another inline element beside it, and set display:inline-block so the width and height can work.

How do you justify text in TD?

HTML | <td> align Attribute left: It sets the text left-align. right: It sets the text right-align. center: It sets the text center-align. justify: It stretches the text of paragraph to set the width of all lines equal.


1 Answers

td[rowspan] {   vertical-align: top;   text-align: left; } 

See: CSS attribute selectors.

like image 119
Tomalak Avatar answered Sep 30 '22 06:09

Tomalak