Why is an empty space between divs when using display: inline-block
, like in this example: http://jsbin.com/IhULuZO/1/edit.
I know I can use float:left
, but I want to get rid of the empty space without floating elements if possible.
Why is an empty space between divs when using display: inline-block
, like in this example: http://jsbin.com/IhULuZO/1/edit.
I know I can use float:left
, but I want to get rid of the empty space without floating elements if possible.
Because the indentation of your code technically is a bunch of whitespace.
<div class="parent">
<div class="child"></div><div class="child"></div><div class="child"></div>
</div>
there is that space between those divs to make them more readable. To delete these spaces, comment all the space in html like this :
<div class="parent">
<div class="child"></div><!--
--><div class="child"></div><!--
--><div class="child"></div>
</div>
It is happening because you have written .child
divs on separate lines. If you write them on same line, extra space will be removed.
<div class="parent">
<div class="child"></div><div class="child"></div><div class="child"></div>
</div>
You should remove the space between .child divs and Code Should Appear Like these.
<div class="parent">
<div class="child"></div><div class="child"></div><div class="child"></div>
</div>