Re: [csswg-drafts] Clarification needed on simultaneous block and inline formatting contexts for block container boxes (#11177)

Thank you for clarifying! I see what you mean: when a block container sets up both a BFC and an IFC, it doesn’t mean that each type of content is part of both contexts at once. Instead, inline content stays within the IFC, while floats interact with the BFC.

My confusion seems to come from the BFC trying to do a lot of different things at once, like:

1. Handling float containment
2. Stopping margin collapse between BFCs
3. Organizing block-level elements

In contrast, the IFC just deals with the layout of inline elements.

What makes things trickier is that a block container is said to "establish" both a BFC and an IFC,  but under different conditions.  A BFC is set up due to certain properties of the block container element, while an IFC happens automatically if the container only has inline content. So, there’s a difference between explicitly creating a BFC and implicitly forming an IFC based on content.

To address this, we could introduce the term 'Flow Formatting Context' (FFC) as a primary framework for flow layout, covering float containment, margin collapse, and the arrangement of both block and inline content.

With this model:

1. If a block container has at least one block element, everything inside gets laid out in a block format. Inline content would automatically wrap in anonymous block boxes.
2. If the container has only inline elements, then everything arranges in an inline format.

With this setup, the FFC would handle flow layout rules, setting up either a BFC (for block layout) or an IFC (for inline layout) as needed. This approach would separate inflow arrangement from float containment and margin collapse, making things simpler.

The note saying that "A block container box can both establish a block formatting context and an inline formatting context simultaneously." feels a bit redundant. 

According to the CSS definition for ["Inline formatting contexts"](https://drafts.csswg.org/css-display/#inline-formatting-context), a BFC isn’t just created "at the same time" as an IFC; rather, a BFC is actually needed for an IFC to exist:

> "Inline formatting contexts exist within (are part of their containing) block formatting contexts; for example, line boxes belonging to the inline formatting context interact with floats belonging to the block formatting context."

This is also noted under ["Formatting Contexts"](https://drafts.csswg.org/css-display/#formatting-context):

> "Additionally, some types of formatting contexts interleave and co-exist: for example, an inline formatting context exists within and interacts with the block formatting context of the element that establishes it"

These statements make it clear: a BFC is a prerequisite for an IFC, not just a coincidental overlap.

-- 
GitHub Notification of comment by gitspeaks
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11177#issuecomment-2469852660 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 12 November 2024 08:10:19 UTC