I was under the impression that hitting Enter to add a line break in my text editor (for the sole purpose of keeping my code tidy/easy to read), has "no effect" on the rendered output.
Apparently I was mistaken. The example in the snippet below clearly shows that my line breaks are adding unwanted spacing after a <span>
.
- I tried
box-sizing:border-box
but it has no effect (presumably since there are no borders). - Negative margins seem to fix the problem, but that doesn't seem like a reasonable solution everywhere I want to add a line break to keep my code tidy.
Why is this happening? Is there a way to avoid this, or should I just code on one really long line from now on?
span {
display: inline-block;
height: 20vh;
width: 10vw;
background-color: red;
}
span:nth-child(even) {
background-color: green;
}
<span></span><span></span><span></span>
<span></span><span></span>
<span></span>
<span></span><span></span><span></span><span></span>
<span></span><span></span><span></span>
<span></span>
<span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span>