CSS Layout How to - Tightly positioned floats








Question

We would like to know how to tightly positioned floats.

Answer


<!DOCTYPE html>
<html>
<body>
  <div style="width: 100px; height: 100px; background-color: #ffff00; float: left; margin: 0 10px;">div1</div>
  <div style="width: 100px; height: 100px; background-color: #0000ff; float: left; margin: 0 10px;">div2</div>
  <div style="width: 100px; height: 100px; background-color: #00ff33; overflow: auto;">div3</div>
</body>
</html>

The code above is rendered as follows: