Re: [csswg-drafts] [css-align] `justify-items` and anonymous block boxes (#11461)

> or always create anonymous block boxes when justify-items is not initial.

I don't follow. Per the [spec](https://drafts.csswg.org/css2/#anonymous%E2%91%A0):

>Any text that is directly contained inside a block container element (not inside an inline element) must be treated as an anonymous inline element. 

In particular, the text in `<div style="width: 200px; justify-items: right; border: solid">foo</div>` would be wrapped in anonymous inline box.

How does introducing an anonymous block box here align with the rules for inline formatting contexts? Are you proposing that `justify-items` implicitly "blockifies" these inline items - effectively changing the formatting context from inline to block? If so, that seems like a substantial semantic shift.

> Note in the 2nd option text-align and justify-items would still do different things,

I suppose in cases where there are multiple lines of different lengths (e.g., due to a `<br>`), `text-align` can affect the alignment of shorter lines - like right-aligning a shorter second line within a shrink-to-fit box defined by the longer first line.

But that feels like a confusing corner case. The box is anonymous, unstyleable, and auto-sized, so people expect no room for alignment to matter. 

I think discarding alignment properties like `justify-items` in inline formatting contexts including those defined by an anonymous text run is not a bad approach. It reduces ambiguity and preserve a clearer separation between inline and block layout behavior.

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


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

Received on Tuesday, 29 April 2025 23:22:17 UTC