katspaugh katspaugh - 1 year ago 130
CSS Question

Iframe creates extra space below

Why does an iframe add extra space under it's element? Look at this weird behavior: http://jsbin.com/UraFalo/1/

enter image description here

How to work around?

Answer Source

Add display:block; to your iFrame style like so:

.border iframe {
    border: none;
    width: 300px;
    height: 100px;
    margin: 0;
    padding: 0;
    opacity: 0.8;
    display:block; /* Add this */


For an explanation to this - iFrame is an Inline Frame, meaning that it is an inline element, which like the img tag, can have issues with whitespace. Setting display:block; on it turns the iFrame into a block element (like a div), which will remove the whitespace issue.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download