CSS Layout How to - Create HTML table-like layout with div and float








Question

We would like to know how to create HTML table-like layout with div and float.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#left {
  height: 200px;
  width: 100px;
  background-color: red;
  float: left;
}<!--   w w w .  j  a v a2 s  .c  o m-->

#right {
  height: 200px;
  width: 100px;
  background-color: yellow;
  float: left;
}
</style>
</head>
<body>
  <div id="left"></div>
  <div id="right">
    <p>Row 1</p>
    <p>Row 2</p>
    <p>Row 3</p>
  </div>
</body>
</html>

The code above is rendered as follows: