tags:

views:

46

answers:

2

This is what I want:

This is the best I could come up with:

CSS

img
{
  background: red;
  float: left;
}

table
{
  background: yellow;
  width: 90%;
}

HTML

<img src="image.jpg" width="40" height="40" />
<table>
  <tr><td>Table</td></tr>
</table>

There is a problem with this approach. If you resize browser window at some point the table jumps below the image: click to view demo.

What is the better way of achieving this layout?

+2  A: 

Try surrounding your table with div like that:

<img src="image.jpg" width="40" height="40" />

<div style="padding-left:40px">       
  <table> 
    <tr><td>Table</td></tr> 
  </table> 
</div>
Draco Ater
Brilliant, thank you very much!
Pavel Chuchuva
+1  A: 

Some people might not like tables, but you could use a table with 2 cells that contains your image on the left and the table on the right.

Mark Redman
This also works but there are 13 reasons why CSS is superior to tables in website design: http://www.chromaticsites.com/blog/13-reasons-why-css-is-superior-to-tables-in-website-design/
Pavel Chuchuva