CSS Spec: block-level box, block container box and block box

前端 未结 2 874
伪装坚强ぢ
伪装坚强ぢ 2020-12-05 08:49

I am reading CSS Spec 2.1 and find the concepts hard to distinguish:

Except for table boxes, which are described in a later chapter, and replaced elem

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 09:36

    Remember that HTML is a tree so each node can act as both a parent (of children) and child (of a parent)

    Bearing this in mind, things start to make sense, Block-level box refers to box act as chlid

    Block-level boxes are boxes that participate in a block formatting context.

    On the other hand, block container box refer to a parent who can contain others

    A block container box either contains only block-level boxes or establishes an inline formatting context and thus contains only inline-level boxes

    Just like a node can either be a child and a parent, an HTML node can either act as a parent(block container box) or child (block-level box) or BOTH

    For example, if children in a node are not allowed (replaced element), it can never be a parent, it can only be a child (Block-level boxes) at most, not a parent (block container box)

    And there is no reason to prevent a non-block parent contain a block parent. An inline-block itself is not a block, but it can contain block-level box

    The point is a spec is easier to understand from a parent-child view

提交回复
热议问题