tags:

views:

48

answers:

7

Ok, I know that using tables for layout is bad. But we have a client that has ie6 installed on all workstations and we have to make a complicated layout that works perfectly on it so the clean CSS solution didn't work so I had to do it with tables.

Here's the HTML code that I have :

<body>
<table id="main_table">
  <tr>
    <td>
      <div class="content">Content</div>
    </td>
  </tr>
</table>
</body>

Here's the CSS that I have :

body{margin:0;padding:0;}
#main_table{border-collapse:collapse;border-spacing:0;width:100%;}
#main_table td{margin:0;padding:0;}
#main_table div.content{margin:0;padding:0;}

And for some mysterious reason, there's some kind of margin between the cell's top and the div. I'm absolutely positive that all my margins and paddings are at 0 but it's still there.

I tried : - a span instead of the div and the problem is still there; - use position:relative on the table cell and position:absolute on the div but the div always take his position from the top left of the browser, not the top left of the element.

Anyone had a similar problem in the past? Thanks in advance for your help.

EDIT : The problem is not only in IE6 but in all browsers.

A: 

I think you want to use #main_table tr td or possibly #main_table tbody tr td to get at the cells and remove their padding and margin, but I'm not 100% sure. Does it display properly in other browsers right now? Can you verify that your css rules are being applied to your cells with something like the IE Developer Toolbar?

g.d.d.c
I should have specified that the problem is not only present in IE6 but in other browsers also... I'll update my question to reflect this.
Gabriel
A: 

ie6 = the enemy of the world. no guarantee but try things like putting "0px" instead of just "0".

Also have you tried putting <table cellspacing="0" cellpadding="0">?

Can't really think of much else.

Can we have a link to play about with?

Thomas Clayson
A: 

Having you tried cellpadding/spacing. I can't test it as I don't have IE6. I don't even support IE6 anymore, Microsoft has dropped support for it and if they no longer support it I'm not going to either.

<table id="main_table" cellpadding="0" cellspacing="0">
Robert
It seems that Microsoft continued to support IE6 for large organisations. Since this problem if for the intranet of a large organisation like that, it's difficult not to support it. The rest of the time, I do not support IE6 anymore...
Gabriel
A: 

Yes I had similar problems, tables have a lot of built in funky rules, especially in IE6. The only was I could fix it was to use divs with CSS and have IE6 specific rules to fix IE box model issues. There might be some IE6 specific issues like this one: http://stackoverflow.com/questions/1158799/internet-explorer-table-1-pixel-spacing-problem

Bayes
A: 

Just add

body { line-height:0;}
metal-gear-solid
A: 

My general-purpose fix for IE-6 padding/margin issues was (because we don't support it anymore) to give the offending container element the IE-proprietary zoom property with a value of 100% to trigger hasLayout. YMMV.

#main_table td div.content { zoom:100%; }
Superstringcheese
A: 

A similar (but not exact) situation occured with another poster some time ago: http://stackoverflow.com/questions/3018484/input-in-table-td-but-yet-extra-bottom-spacing-between-rows-internet-explore/3018862#3018862

Mark Schultheiss