1

My current css is

.container {
display: block;
width: 400px;
height: auto;
padding: 0px 0px;
background-color: #ffffff;
border: black 1px solid;
}
.container img {
width: 100%;
}

And html is

<div class="container">
<img src="http://67.media.tumblr.com/15b26a66682a68facad249bd442ced38/tumblr_nw48hrdLfp1sikueao2_1280.jpg">
</div>

enter image description here

Here is the result, how do i get rid of the white space below the image?

dovla
  • 191
  • 2
  • 4
  • 11

2 Answers2

2

hello apply display block to image

div img {
  display: block;
}
1

Default display for img elements is inline and that white space below image is space for descenders on letters like j, y, g... You can fix that by adding vertical-align: top

.container {
  display: block;
  width: 400px;
  height: auto;
  padding: 0px 0px;
  background-color: #ffffff;
  border: black 1px solid;
}
.container img {
  width: 100%;
  vertical-align: top;
}
<div class="container">
  <img src="http://placehold.it/350x150">
</div>
Nenad Vracar
  • 118,580
  • 15
  • 151
  • 176