Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing unwanted margin / padding from embedded content

I have embedded a SoundCloud widget on my page below an image.

There is a small space between the bottom of the image and the top of the widget. I've used Web Inspector to track down where this gap is coming from but I cannot find it. I would like to remove this space.

The code is quite simple:

<img src="http://upload.wikimedia.org/wikipedia/commons/8/85/Image-New_Delhi_Lotus.jpg">
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F66379982?"></iframe>

View the code in action: http://jsfiddle.net/LAn3A/

I can't even tell if this gap is due to a border, padding or a margin. I am certain it is coming from the SoundCloud widget though.

like image 961
Olly F Avatar asked Jul 15 '26 15:07

Olly F


1 Answers

This can happen when you try closely position an inline element next to a block-level element. Text properties such as line-height get in the way. Fix it by setting the image to a block level element:

img { display: block;}
like image 82
KatieK Avatar answered Jul 17 '26 18:07

KatieK