0

Run the snippet below, and you will see that these two balck boxes occupy more space than they need (vertically). Why is that so? I have tried settting margin / padding to 0, but it did not work.

div.ex4 {
  display: block;
  background-color: lightblue;
  overflow: visible;
}

.imag {
    width: 20px;
    height: 20px;
    background-color: black;
    display: inline-block;
    margin: 0px;
    padding: 0px;
}
<div class="ex4"><div class="imag"></div><div class="imag"></div></div>
Ruslan Plastun
  • 1,985
  • 3
  • 21
  • 48

1 Answers1

0

use font-size: 0;

div.ex4 {
  display: block;
  background-color: lightblue;
  overflow: visible;
font-size: 0;
}

.imag {
    width: 20px;
    height: 20px;
    background-color: black;
    display: inline-block;
    margin: 0px;
    padding: 0px;
}
<div class="ex4"><div class="imag"></div><div class="imag"></div></div>
ebyte
  • 1,469
  • 2
  • 17
  • 32