If a <div>
or any other element follows an <img>
, then a ~3px whitespace appears in between them — even if margins
are zero'd.
<img src="example-fractal-art.png">
<div>What is with that gap?<div>
Here's what it looks like with some CSS.
Now it's pretty easy to throw in display: block
into the CSS and solve the problem. But why is it there? There are no computed margins, padding, borders, or anything like that.
What are the browsers doing? Someone even called it "magic".
P.S. Alternatively, in some cases, it is possible to solve this by removing whitespace in the HTML code. (But that doesn't work in this case, why?)