Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysterious gap under image appearing [duplicate]

Tags:

html

css

image

Possible Duplicate:
White space at bottom of anchor tag

Check out this sample page here.. http://denise.brixwork.com/

For some odd reason, under that pic of that family, there's a gap before the grey border (5px #333) div that contains the image. I removed all margins, paddings etc. and it still wont' disappear. :(

Short of setting a fixed height on the #index_content div, which i don't want in case the image has to be re-sized later (which means double the work for me), how can I remove that gap while leaving it elastic?

My HTML Code:

<div id="index_content_container">
    <div id="index_content">
        <img src="http://denise.brixwork.com/images/index_photo.jpg" alt="Real Whistler Living - Real Estate for the Next Generation" />
    </div>
    <div class="clear"></div>
</div>

The CSS:

/* INDEX PAGE SPECIAL CSS */
#index_content_container {
    position: relative;
    width: 970px;
    border: 5px solid #e1bb14;
    left: -20px;
    display: block;
    float: left;
    padding: 0px;
    margin: 0px;
}

#index_content {
    position: relative;
    width: 960px;
    border: 5px solid #333;
    float: left;
    display: block;
    padding: 0px;
    margin: 0px;
}

#index_content img {
    padding: 0px;
    border: none;
    margin: 0px;
    clear: none;
}
like image 644
jeffkee Avatar asked Jun 15 '12 20:06

jeffkee


People also ask

How do I get rid of the extra white space under an image in CSS?

Line Height Property: The CSS line-height-property can be used to set the height of the line, whose value is set to normal, by default. By setting the height of the container at 0%, the white space can be removed.

How do I remove the space under an image in a table cell?

Tutorial Categories: In IE7, if you have a table cell with an image displayed in it, you may have noticed a small space underneath the image in the table cell. This space occurs in IE7 but not Firefox. This space can be removed by setting the style of the image to be 'block' rather than 'inline'.


2 Answers

Try this:

#index_content img{
padding: 0px;
border: none !important;
margin: 0px;
clear: none;
display: block;
}
like image 124
Adam Flatau Avatar answered Oct 18 '22 06:10

Adam Flatau


You only need display: block in your img tag, nothing else =)

like image 25
leopic Avatar answered Oct 18 '22 06:10

leopic