Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox and Chrome adds 2px bottom padding to the table cell when there is iframe inside the cell in standard mode

I was working on an intranet application which has been working on quirks mode in all major browsers for years. The goal was to make it work in standard mode without breaking anything so that we can use some jQuery packages. Anyway my problem is in standard mode Firefox and Chrome adds a 2px bottom padding to the table cell when there is an iframe inside the cell. This does not happen in IE.

When I switch to quirks mode the padding goes away in Firefox and Chrome.
When I add a div instead of an iframe the padding goes away.
Setting table cellpadding and cellspacing to zero doesn't help.
The iframe src page is also in standard mode.

Here is a test case for you to see:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head><title>Test</title></head>
<body style="background:#FFF;">
<table cellpadding="0" cellspacing="0" border="0">
      <tr>
            <td id='browser_td' style='width:1000px; height:500px; margin:0px; padding:0px; background:#000; border-bottom:0px;'>
                  <iframe id='browser_iframe' name='browser_iframe' src="http://houston.craigslist.org/" width='1000' height='500' frameborder="0" hspace="0" vspace="0"></iframe>
            </td>
      </tr>
</table>
</body>
</html>
like image 761
icramc Avatar asked Feb 24 '12 17:02

icramc


1 Answers

Add vertical-align: top to iframe. The initial value of vertical-align is baseline.

iframe is an inline element. The problematic gap is the space reserved for descenders in letters.

More information here: https://developer.mozilla.org/en/Images,_Tables,_and_Mysterious_Gaps

like image 196
thirtydot Avatar answered Sep 21 '22 06:09

thirtydot