I used to think line breaks don't have any effect in the rendering of html that's how minification works. But then I stumbled on something weird
<!DOCTYPE html>
<html>
<body>
<style>
div { width: 200px; background: silver; margin: 30px; display: block!important; }
span { border: 1px solid yellow; display: inline!important; }
</style>
<!-- div1 -->
<div><span>Apple</span><span>Apple</span><span>Apple</span><span>Apple</span><span>Apple</span><span>Apple</span></div>
<!-- div2 -->
<div>
<span>Apple</span>
<span>Apple</span>
<span>Apple</span>
<span>Apple</span>
<span>Apple</span>
<span>Apple</span>
</div>
</body>
</html>
Both div1 and div2 are identical except for former is minified and lacks newlines
As you can see spans in div2 line-up and wrap perfectly as inline elements are supposed to but in div1 they don't. Moreover I see some strange gap between <span>
s
Any thoughts as to why it is so?
UPDATE:
So by helpful comments I got it why the spans don't wrap around because they have no space and therefore behave like a LONG WORD like
"lallalalalalallalalalalaalalalalalalalalalalalalallaalalalallallalalalalallalalalalaaaa"
which normally never wraps around and overflows container. Fixed it after realizing word-break: break-word
works on spans too.