Friday, 18 March 2011

iframe mysterious 3px margin

If you have some HTML like:

<iframe ...></iframe>
<div></div>

... you'll have a mysterious 3px gap between the elements even though everything says the margins are all zero. Rather than putting a margin-top="-3px" on the div, the better solution is to change the <iframe> to display:block.

Yup ... <iframe>'s default to display inline. Who would have guessed that!

1 comment:

  1. excellent!

    I was hours looking for a solution ... very good!

    thanks!

    ReplyDelete