This question already has an answer here:
In Firefox only my video thumbnails are displaying mysterious 2-3 pixels of white space between the bottom of my image and its border (see below).
I've tried everything I can think of in Firebug with no luck.
How can I remove this white space?
Had this prob, found perfect solution elsewhere if you dont want you use block just add
Give the height of the div
.youtube-thumb
the height of the image. That should set the problem in Firefox browser.I found this question and none of the solutions here worked for me. I found another solution that got rid of the gaps below images in Chrome. I had to add
line-height:0;
to the img selector in my CSS and the gaps below images went away.Crazy that this problem persists in browsers in 2013.
If you would like to preserve the image as inline you can put
vertical-align: top
orvertical-align: bottom
on it. By default it is aligned on the baseline hence the few pixels beneath it.As stated before, the image is treated as text, so the bottom is to accommodate for those pesky: "p,q,y,g,j"; the easiest solution is to assign the img display:block; in your css.
But this does inhibit the standard image behavior of flowing with the text. To keep that behavior and eliminate the space. I recommend wrapping the image with something like this.
I've set up a JSFiddle to test several different solutions to this problem. Based on the [vague] criteria of
The accepted answer here of
which is recommended by a lot of people (such as in this excellent article), actually ranks fourth.
1st, 2nd, and 3rd place are all a toss-up between these three solutions:
1) The solution given by @Dave Kok and @Hasan Gursoy:
pros:
cons:
2) Setting
font-size: 0;
on the parent element:Since this one [kind of] requires
vertical-align: top
on theimg
, this is basically an extension of the 1st solution.pros:
cons:
3) Setting
line-height: 0
on the parent element:Similar to the 2nd solution in that, to make it fully flexible, it basically becomes an extension of the 1st.
pros:
cons:
So there you have it. I hope this helps some poor soul.