HTML Element Style How to - Stack two div right








Question

We would like to know how to stack two div right.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#wrapper2 {<!--from  w  w  w.ja  v a  2  s . co  m-->
  border: 1px solid black;
}

#yellow {
  background: yellow;
  width: 100px;
  height: 200px;
  float: left;
  margin-right: 50px;
}

#red {
  height: 100px;
  background: red;
  overflow: hidden; /**/
}

#blue {
  height: 100px;
  background: blue;
  overflow: hidden; /**/
}
</style>
</head>
<body>
  <div id="wrapper2">
    <div id="yellow">YELLOW</div>
    <div id="red">RED</div>
    <div id="blue">BLUE</div>
  </div>
</body>
</html>

The code above is rendered as follows: