On two different projects I learned two different methods of positioning two div
s horizontally next to each other. Is one better than the other, or is it just a matter of personal taste, or maybe one is only working by coincidence?
Method one:
.container,
.div1,
.div2 {
border: 1px solid red;
}
.div1,
.div2 {
float: left;
}
<div class="container">
<div class="div1">
DIV1
</div>
<div class="div2">
DIV2
</div>
<div style="clear: both;"></div>
</div>
Method two:
.container,
.div1,
.div2 {
border: 1px solid green;
}
.div1,
.div2 {
display: inline-block;
}
<div class="container">
<div class="div1">
DIV1
</div>
<div class="div2">
DIV2
</div>
</div>