Björn Schönrock Björn Schönrock - 7 months ago 9
HTML Question

Contents of table are not aligned left

I want the

<img>
and
Test
to be aligned left, but they aren't.

My code:

<center>
<div class="body" id="block">
<span style="width:95%;background-color: rgb(247,247,247);border-radius:10px;display:block;">
<table>
<tr style="height:25px;">
<td style="width:70%;margin-left:10px;font-size:20px;text-align:left;display:block;">
<img style="height:20px;" src="http://i64.tinypic.com/2i9qzj5.png">
Test
</td>
<td style="font-size:12px;">
Another test
</td>
<td style="width:5%;">
</td>
<td style="width:15%;font-size:12px;">
Third test
</td>
</tr>
</table>
</span>
</div>
</center>


I've tried several things, but still does not work.
I don't understand what I'm doing wrong here.

Answer

Remove CSS display:block of <td> tag:

<td style="width:70%;margin-left:10px;font-size:20px;text-align:left;display:block;">

New code:

<td style="width:70%;margin-left:10px;font-size:20px;text-align:left;">

By default, <td> in table has CSS: display: table-cell;

True answer:

 table { width: 100%; }
Comments