In the CSS spec in sec 9.2.1 said:
Except for table boxes, which are described in a later chapter, and replaced elements, a block-level box is also a block container box. A block container box either contains only block-level boxes or establishes an inline formatting context and thus contains only inline-level boxes. Consider the markup:
<div id="d">
<div>Anonymous text</div>
<span>Some text</span>
<span>Another some text</span>
<div>Another anonymous text</div>
</div>
and styles:
div#d{
width: 300px;
height: 300px;
background: aqua;
}
In my case div#d
contains block-level and inline-level boxes. But in the sec. 9.2.1.1 said that
if a block container box (such as that generated for the DIV above) has a block-level box inside it (such as the P above), then we force it to have only block-level boxes inside it.
Q: Why we can put inside the block-level element (e.g. div
) both inline and block elements and they will displayed as inline and block element, but in spec said that block container box either contains only block-level boxes or establishes an inline formatting context and thus contains only inline-level boxes.
I'm confused. Can you dispel my doubts?