The CSS white-space property is defined in sections 3 and 4 of the css-text-4 specification: https://drafts.csswg.org/css-text-4/#white-space-property. It is a very important property for accurately reproducing how browsers lay out text. And can also be used to account for differences between desired behaviour between editable and non-editable text around how whitespace is "hung" at the end of lines.
(the emojis in this issue were not generated by AI)
It is considered a "shorthand" property that decomposes into the following longhands:
✅ text-wrap-mode
This property has two variants: wrap and nowrap. nowrap disables wrapping entirely.
enum TextWrapMode {
Wrap,
NoWrap,
}
Status: fully implemented.
⚠️ white-space-collapse
This property controls:
- ⚠️ How whitespace is collapsed
- ❌ How whitespace at the end of the line is "hung" (or not hung)
enum WhiteSpaceCollapse {
Collapse,
Discard,
Preserve,
PreserveBreaks,
PreserveSpaces,
BreakSpaces,
}
See spec (https://drafts.csswg.org/css-text-4/#white-space-collapsing) for the meanings of each variant.
Status: we currently implement only the Collapse and Preserve variants in a somewhat hacky way in the TreeBuilder, and we also only implement the "white space collapsing" behaviour, and do not implement the different "whitespace hanging" behaviours (implementing the latter will require us to pass WhiteSpaceCollapse into layout as a style which we do not currently do).
See also: discussion on #485 which attempted fixes for whitespace hanging behaviour.
⚠️ white-space-trim
Controls "whitespace trimming" at the beggining and end of spans.
enum WhiteSpaceCollapse {
DiscardBefore,
DiscardAfter,
DiscardInner,
}
Status: some basic trimming is implemented hackily in the TreeBuilder, but there are bugs in the current implementation. And it also doesn't allow full control over the trimming using a style.
The CSS
white-spaceproperty is defined in sections 3 and 4 of the css-text-4 specification: https://drafts.csswg.org/css-text-4/#white-space-property. It is a very important property for accurately reproducing how browsers lay out text. And can also be used to account for differences between desired behaviour between editable and non-editable text around how whitespace is "hung" at the end of lines.(the emojis in this issue were not generated by AI)
It is considered a "shorthand" property that decomposes into the following longhands:
✅
text-wrap-modeThis property has two variants:
wrapandnowrap.nowrapdisables wrapping entirely.Status: fully implemented.
white-space-collapseThis property controls:
See spec (https://drafts.csswg.org/css-text-4/#white-space-collapsing) for the meanings of each variant.
Status: we currently implement only the
CollapseandPreservevariants in a somewhat hacky way in theTreeBuilder, and we also only implement the "white space collapsing" behaviour, and do not implement the different "whitespace hanging" behaviours (implementing the latter will require us to passWhiteSpaceCollapseinto layout as a style which we do not currently do).See also: discussion on #485 which attempted fixes for whitespace hanging behaviour.
white-space-trimControls "whitespace trimming" at the beggining and end of spans.
Status: some basic trimming is implemented hackily in the
TreeBuilder, but there are bugs in the current implementation. And it also doesn't allow full control over the trimming using a style.