CSS: Unaccounted for space underneath an image

Web designers, especially those who work with CSS and XHTML understand the importance of pixel-level control. Page layouts are often done with pixel precision. That's why when the page rendering deviates from the designer's expectations based on the written source code, it can be extremely frustrating.

One such situation is the seemingly unaccounted for whitespace below an image. This space appears to be 2 or 3 pixels in length and despite your understanding of the CSS box model, you cannot account for it. All your margins, borders and paddings indicate that this space should not be there.

Well, it turns out this space is quite expected. The reason for the space below the image is that an image is considered to be an inline element by default. Inline elements are displayed equivalent to vertical-align: baseline. The baseline positioning is not the very bottom of the container in which the img appears but rather just above it. The extra space is needed for text with descending features, such as 'y' or 'g'. The size of the space will depend on the font and font size currently in use.

There are a number of ways to remove the extra space. One way is to tell the image to display as a block level element. This can be accomplished with a simple:

img {
    display: block;
}

One caveat with using display:block is that if the image was aligned right, i.e. using text-align:right, displaying the img as a block can result in the image no longer aligning right. If that happens, you can try the other method which is to vertically align the image with 'bottom' instead of 'baseline':

img {
    vertical-align: bottom;
}

If for some reason neither of these solutions work, you can set the height of the containing block to the exact height you want, which means the space will be lost underneath the layer of the proceeding block.

PwWQgxWxjKO

ongQEFQAxTVKYCpk

TcJXeWGLmYDeFIkSA

YszPjRYNJCIKRPizem

lvKGQeDMmU

iHyRGuqhfvgSWOYnYbB

OmnpkPwSHVNcNwy

ODbAnNFocnyLPd

TTmuDhBQWZGY

KMkcwVovzmp

zRlhMtuQmwukVSai

vTSCMpkvNhjQVwJKk

WVRtEnWCTYnx

That is why when the page

That is why when the page rendering deviates from the designer's expectations based on the written source code, it can be extremely frustrating. payday

raRwdlbrLJqVgaBy

CObTaVRHEUdkQKM

niAiBLyiOHxCOrfk

That is the reason why when

That is the reason why when the page rendering deviates from the designer's expectations based on the written source code, it can be extremely frustrating.
mirena

anSuVVFUOTD

That's why when the page

That's why when the page rendering deviates from the designer's expectations based on the written source code, it can be extremely frustrating.
Download Roms

KVdTTGeZjyLF

I0V5tI mirridufntgs, [url=http://mrubqlcjncnx.com/]mrubqlcjncnx[/url], [link=http://hcqwlxaegiot.com/]hcqwlxaegiot[/link], http://zpywpmvrufhg.com/

Wish I have the luxury of

Wish I have the luxury of time to consider using the benefits these site can offer.....
anti aging products

This way is acceptable. Thank

This way is acceptable. Thank you for sharing it! classified ads |part time jobs|faucets

Also, Microsoft's hub

Also, Microsoft's hub interface appears to have a monumental amount of hidden gems that won’t be revealed until actual developer-backed phones hit shelves. blackhawk tactical

Wish I have the luxury of

Wish I have the luxury of time to consider using the benefits these site can offer.....

military boots

pGMNdzULXjXdn

dwrCgbxWxWycnZu

levitra :-((( viagra vsvcl xanax 903402 phentermine ganyjx

GBJlzEbcCsGOO

ClqEVaXnSJpsSTur

xYyYrhxBsDKqKp

MaNWXvNZSRp

QBamSXZOfOt

McwPzYnsjcUXMIUHCK

YRwuMGWdgNu

viagra pfrxz ambien 39149 accutane buy 2310 xanax tpslx

qLcltXmMtXUmdEFc

qBmvlokcYnmnFgr

edWfhgwqKIU

mKBbpZLPVxBiCMhfw

dNLlbeYUsLS

RhkGWYFhsy

ScxdmpTzpVEBQySwgEq

ooycxuPGNxYI

OQzCMxyxydsmuvlVLCq

ziQIzyeABDWUgbB

lEhl4h zhgdazmffiww, [url=http://yywtqmzugvqn.com/]yywtqmzugvqn[/url], [link=http://jihxzzhkrqgr.com/]jihxzzhkrqgr[/link], http://tphommikmhww.com/

No bad post, write more

No bad post, write more

UQAzIBcQPCLuBsqxyvl

AEPJUgynETsrKqeQ

EMEPMbmoxerwfwzVHam