CSS Layout How to - Avoid Line-Break Padding








Question

We would like to know how to avoid Line-Break Padding.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.Foo {<!--from w  w w  .  j  av  a  2 s. c  o  m-->
  display: inline-block;
  width: 25%;
  background-color: lime;
}

.Bar {
  display: inline-block;
  width: 25%;
  background-color: orange;
}
</style>
</head>
<body>
  <div class="Foo">
    <p>This is Foo.</p>
  </div>
  <div class="Bar">
    <p>This is Bar.</p>
  </div>
  <br>
  <br>
  <div class="Foo">
    <p>This is Foo.</p>
  </div>
  <div class="Bar">
    <p>This is Bar.</p>
  </div>  <div class="Foo">
    <p>This is Foo.</p>
  </div>
  <div class="Bar">
    <p>This is Bar.</p>
  </div>
  <br>
  <br>
  <div class="Foo">
    <p>This is Foo.</p>
  </div>
  <div class="Bar">
    <p>This is Bar.</p>
  </div>
</body>
</html>

The code above is rendered as follows: