Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Misaligned content in table cells

I am making some table content and got some problems.
When i want to add more text to first table column, it adds extra space do all other columns.
Here u can see what i am saying about
enter image description here

U can check my fiddle here

HTML

<table id="mytable" border="1">
    <tr>
        <td>
            <img src="" />
                <span>some text<br>asdasd<br>asdas</span>
        </td>
        <td>
            <img src="" />
                <span>some text</span>
        </td>

    </tr>
</table>

CSS

    #mytable{
    width:400px;
}
#mytable tr td{
    padding:10px;
}
#mytable tr td img{
    width:200px;
    height:100px;
}
like image 399
Crion Avatar asked Jul 17 '26 16:07

Crion


2 Answers

You should set the vertical-align for your td elements

#mytable tr td{
    padding:10px;
    vertical-align: top; /* Add this */
}

Demo

like image 136
Mr. Alien Avatar answered Jul 19 '26 06:07

Mr. Alien


You could do it by using vertical-align: top; to #mytable tr td

JSFiddle - DEMO

HTML:

<table id="mytable" border="1">
    <tr>
        <td>
            <img src="" /> <span>some text<br>asdasd<br>asdas</span>
        </td>
        <td>
            <img src="" /> <span>some text</span>
        </td>
    </tr>
</table>

CSS:

#mytable{
    width:400px;
}
#mytable tr td{
    padding:10px;
    vertical-align: top;
}
#mytable tr td img{
    width:200px;
    height:100px;
}
like image 41
Anonymous Avatar answered Jul 19 '26 04:07

Anonymous



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!