Skip to content

[css-text-3] When is allowed to break before the first preserved white-space after a word ? #3701

Description

@javifernandez

It may be other cases, but I'd like some clarification regarding how to deal with preserved white-spaces character generated by the white-space: break-spaces feature.

According to the spec,it must break AFTER any white-space:

A line breaking opportunity exists after every preserved white space character, including between white space characters.

However, depending on the case and in combination with other CSS properties, there may be soft-breaking opportunities BEFORE the first space after a word. The following table describes what I think is the expected behavior when using white-space: break-spaces in combination with other properties:

propertyvaluebreak beforeConditional
overflow-wrapnormalNoNever
break-wordYesIf no previous opportunity
anywhereYesIf no previous opportunity
word-break normalNoNever
break-allNoNever
keep-allNoNever
line-breakanywhereyesAlways

Is the content of this table correct, according to the last draft of the spec ?

Assuming it's correct, lets consider the following example:

<style>
div {
  width: 4ch;
  line-height: 1;
  border: 1px solid;
}
</style>

<div>X XX X</div>

The table bellow shows Chrome's current behavior when loading the example above with the different combination of the line-breaking properties:

caseword-breakoverflow-wrapline-breakresult
0normalnormalauto
1normalbreak-wordauto
2normalanywhereauto
3break-allnormalauto
4break-allbreak-wordauto
5normalnormalanywhere
6break-allnormalanywhere
7normalbreak-wordanywhere
8break-allbreak-wordanywhere

Are all these cases correctly rendered ?

Metadata

Metadata

Assignees

Labels

Closed as Question AnsweredUsed when the issue is more of a question than a problem, and it's been answered.Commenter SatisfiedCommenter has indicated satisfaction with the resolution / edits.TestedMemory aid - issue has WPT testscss-text-3Current Work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions