Skip to content

[css-contain] containment vs baseline alignement #2995

@frivoal

Description

@frivoal

I think the spec is a little bit unclear, and probably partially wrong, when it comes to the interaction of containment and baseline alignment.

  • If a non-empty inline-block has size containment, how should it be aligned in the line box that contains it? The way I understand size containment, it is only supposed to affect the size of the element with containment, causing it to be sized as if it was empty. This would mean that unlike an empty inline-block where we align the bottom margin edge with the parent's baseline (see CSS2 10.8), we would align the baseline of the box with the parent's baseline as we would do if the element had an explicit width and height of 0 instead of size containment.

    I am unsure about the meaning of what the spec currently says:

    When laying out the containing element, it must be treated as having no contents.

    After layout of the element is complete, its contents must then be laid out into the containing element’s resolved size.

    I think it only implies what I said above, but I am not sure. I suggest clarifying by changing to:

    When calculating the size of the containing element, it must be treated as having no contents.

    Then, its contents must then be laid out into the containing element’s resolved size.

  • On the other hand, it seems to me that layout containment should negate the ability to do baseline alignment, otherwise, internal changes in the layout of the element would be able to affect it's surroundings. Therefore, I suggest we add this to the list of effects of layout containment:

    For the purpose of the 'vertical-align' property, or any other property whose effects need to relate the position of the containing element's baseline to something other than its descendants, the containing element is treated as having no baseline.

    The "any other property" part is meant to catch things like box-snap.

This is not what the Blink implementation does: it turns off baseline alignment on size containment, not on layout containment (see test case).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions