Search code examples
htmlcsstexthtml-tableposition

Table position text css


I want to have my text on the top-left in the 3rd cell.

Here is my example: http://jsfiddle.net/24nd5/

<table border="1" style="width: 100%;">
<tr>
    <td style="width: 15%;">
        lol lol lol lol lol
        lol lol lol lol lol
        lol lol lol lol lol
        lol lol lol lol lol
    </td>
    <td style="width: 3%;">

    </td>
    <td style="">
        Name
    </td>
</tr>
</table>

Solution

  • To make it more dynamic you can add:

    table tr td:last-child  { vertical-align:top; }
    

    or

    table tr td:nth-child(3) { vertical-align:top; }
    

    Fiddle here

    Now if you add more rows each last cell (or third depends on which code you use from the above) wil have the text in the left top corner

    Fiddle here