I was used to using floats for creating layouts but today i realized inline block can also be used for the same purpose. This is the html
<div class="col">
</div>
<div class="col">
</div>
<div class="col">
</div>
I am wondering what is the difference between using inline block and float in creating 3 columns layout.
Using float
.col {
border: 1px solid black;
width: 30%;
float:left;
height: 200px;
}
Using inline block
.col {
border: 1px solid black;
width: 30%;
display: inline-block;
height: 200px;
}
Apart from a slight margin when using inline block they seem identical. Is there a recommended way on whether to use float or inline block in order to create layouts such as this? I appreciate any help to this dilemma. Thanks!