Alternative title: Please help me understand the CSS visual formatting model.
I'm reading the W3C Editor's Draft for CSS2.
From section 9.2.2., with my emphasis,
Inline-level elements are those elements of the source document that do not form new blocks of content; the content is distributed in lines [...]. The following values of the display property make an element inline-level: inline, inline-table, and inline-block.
Inline-level elements generate inline-level boxes, which are boxes that participate in an inline formatting context.
So the following span elements should generate inline-level boxes.
<span>Hello.</span><span>Hallo.</span><span>Hello.</span><span>Hallo.</span><span>Hello.</span>
But to be safe we can make that explicit.
span {
display: inline;
}
Then, from section 9.4.2,
When several inline-level boxes cannot fit horizontally within a single line box, they are distributed among two or more vertically-stacked line boxes. Thus, a paragraph is a vertical stack of line boxes.
But if you resize the document containing the spans, they don't wrap, i.e., they're not distributed among two or more line boxes. Changing their display property to inline-block fixes the problem, even though inline-block elements generate inline-level boxes.
From section 9.2.2.,
Inline-level boxes that are not inline boxes (such as replaced inline-level elements, inline-block elements, and inline-table elements) are called atomic inline-level boxes because they participate in their inline formatting context as a single opaque box.
Adding spaces between the spans also fixes the problem, but I'm not sure why. The wording of the normal value of the white-space property is not very specific.
Sequences of white space are collapsed. Newline characters in the source are handled the same as other white space. Lines are broken as necessary to fill line boxes.
When is it necessary to fill a line box?