Consider the following HTML & CSS:
<div><img src='http://makandra.com/images/makandra-ruby-on-rails.png' /></div>
^
img {
background-color: red;
}
div {
border: 1px solid black;
}
This will leave a margin of about 5px between the lower edge of the image and the containing div, although there are no paddings or margins set, and there's no whitespace. The reason is, the image will vertically align baseline
, and the space below the image is just kept for descenders (the part of letters below the baseline).
Fix it by either giving the image a vertical-align: middle
or display: block
, which in most cases should be what you want.
Posted by Dominik Schöler to makandra dev (2012-05-31 07:01)