HTML Element Style How to - Float two div elements left








Question

We would like to know how to float two div elements left.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.main {<!--   w w w.  j a  v  a2s.c  o m-->
  float: left;
  width: 580px;
  background: red;
}

.number {
  width: 40px;
  float: left;
  padding: 5px;
}

.description {
  width: 519px;
  float: left;
  border-left: 1px solid #000;
  padding: 5px;
}
</style>
</head>
<body>
  <div class="main">
    <div class="number">100</div>
    <div class="description">bla bla bla bla bla bla bla bla bla bla
      bla bla bla bla bla bla bla bla bla bla bla</div>
  </div>
</body>
</html>

The code above is rendered as follows: