Correcting for line descent in Firefox
I was working on a theme for the image gallery Plogger when an old problem cropped up again. I was adding links to thumbnail images, and had given the anchor a padding of 3 pixels and a 1 pixel border so that the link formed a sort of picture frame around the image. It looked fine in IE7, with a consistent 3 pixels of space on all 4 sides of the image between the image and the anchor’s border. But in Firefox, the top and sides had 3 pixels of space between the image and the anchor’s border, but the bottom had 5 pixels of space. For some reason, an additional 2 pixels of space was appearing below the image, between the image and the bottom border of the anchor.
This gap below linked images had plagued me in the past, and I had always just found an alternate means, such as applying the padding and/or border to the image. But this time, I decided to figure out what was going on. I Googled for awhile and finally hit on a forum thread that explained the fix. As it turns out, Firefox allows for something called ‘line descent’, which, in typography, is the amount of space below the baseline of a font.
Most scripts share the notion of a baseline: an imaginary horizontal line on which characters rest. In some scripts, parts of glyphs lie below the baseline. The descent spans the distance between the baseline and the lowest descending glyph in a typeface, and the part of a glyph that descends below the baseline has the name “descender”.
So the descender would be the lowest portion of lowercase letters such as ‘g,’ ‘j,’ ‘p.’ ‘q,’ and ‘y’. Why Firefox wants to accommodate that by adjusting the bottom of an anchor tag remains a mystery to me.
The fix is to add img {vertical-align: bottom;} where appropriate to your CSS. In practice, it eliminates the gap in Firefox by pulling up the bottom of the anchor, rather than by pushing down the image. There is no apparent change in IE7.










Thank you for this. I have been banging my head against this problem for the last hour and finally found your solution. Solved my problem. Thank you!
October 5th, 2007
Thank you so much! That solved my problem! I was going mad!
December 18th, 2007
Thank you! you’re my hero! :))
February 4th, 2008
Thanks, this solved my problem!
July 31st, 2008