[csswg-drafts] [css-text-4] White Space Processing Phase 2 questions (#13695)

afishhh has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-text-4] White Space Processing Phase 2 questions ==
So I'm looking to implement correct white space handling however I'm not sure I correctly understand some things about [css-text-4 § 4.3.2 Phase II: Trimming and Positioning](https://drafts.csswg.org/css-text-4/#white-space-phase-2).

---

The section begins with *<q>taking [bidi reordering](https://drafts.csswg.org/css-writing-modes-4/#text-direction) into account</q>* then *<q>As each line is laid out</q>* which makes it unclear whether the individual points refer to text "before bidi reordering" or "after bidi reordering" by default (we're supposedly "taking bidi reordering into account" but in what way?).
This doesn't matter for points 3 and 4 either because of bidi rule L1 or because it's explicitly specified to be after reordering.
Now, point 1 says *<q>A sequence of [collapsible](https://drafts.csswg.org/css-text-4/#collapsible-white-space) [spaces](https://drafts.csswg.org/css-text-4/#spaces) at the **beginning of a line** is removed</q>* but doesn't clarify this. Putting an implementer hat on leads me to believe it's probably "before bidi reordering" because otherwise line-breaking becomes much harder (which the spec seems to carefully avoid in other parts).
Is my assumption correct here? If so, maybe the spec could use some clarification?
(A similar question could be asked about point 2, but to be honest I have no idea how tabulation is supposed to work in CSS at all and don't really care about it in my implementation for now)

If this does refer to the logical beginning (before reordering), is it correct that this only matters if this is the first line since otherwise these spaces would just be hanged on the previous one?
(At first I thought breaking the last line on a `break-spaces` space would also be a case here, but careful spec-reading would suggest that's not the case since that space would end up at the beginning and wouldn't be collapsible)

---

It's also unclear what happens with point 4 in cases where the sequence of trailing spaces is part of multiple spans with different `white-space-collapse`. I devised a test for it [here](https://gist.github.com/afishhh/ee258541143d72a3df48db389943a73e) and I agree with Firefox's behavior the most (collapsing the advance smoothly is just showing off :)). I can't make sense of what Chromium and WebKit do here so that makes me a bit confused, it seems neither are even close to correct?

---

Site note: Is this issue tracker the correct place to ask such questions? Maybe the one about point 4 could just be a separate spec issue too, not sure.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13695 using your GitHub account


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

Received on Friday, 20 March 2026 21:32:31 UTC