It seems that HTML by default puts damn " whitespace-only text node
" between inline elements with this I get a "margin" between elements that I can not remove from DOM
I know there are solutions like putting display:flex
in the parent, or putting float
in the elements. But I wanted to remove all these whitespace node
at once without needing these artifacts (or gambiarras as margin-left:-4px
).
FireFox shows DevTools these nodes
Hereisanothersimpleexamplesimulatingtheproblem:
ul li {
display: inline-block;
padding: 10px;
background-color: palevioletred;
}
<h2>Exemplo com Imagem</h2>
<div>
<img src="http://unsplash.it/100/100"alt="">
<img src="http://unsplash.it/100/100"alt="">
<img src="http://unsplash.it/100/100"alt="">
<img src="http://unsplash.it/100/100"alt="">
</div>
<br>
<img src="http://unsplash.it/100/100"alt=""><img src="http://unsplash.it/100/100"alt=""><img src="http://unsplash.it/100/100"alt=""><img src="http://unsplash.it/100/100"alt="">
<br>
<h2>Exemplo com ul/li { display:inline-block }</h2>
<ul>
<li>item|</li>
<li>item|</li>
<li>item|</li>
<li>item|</li>
</ul>
<br>
<ul>
<li>item|</li><li>item|</li><li>item|</li><li>item|</li>
</ul>