-
Notifications
You must be signed in to change notification settings - Fork 728
[css-text] Introduce a text-wrap-style value focused on orphans #10837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
62c13c9
75b9d6f
6c5a465
7133ac8
f160c5d
f474aaa
255cd9e
cf869ac
b7317a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5501,7 +5501,7 @@ Selecting How to Wrap: the 'text-wrap-style' property</h3> | |||||
|
||||||
<pre class="propdef"> | ||||||
Name: text-wrap-style | ||||||
Value: auto | balance | stable | pretty | ||||||
Value: auto | balance | stable | pretty | reduce-orphans | ||||||
Initial: auto | ||||||
Applies to: [=block containers=] hat establish an [=inline formatting context=] | ||||||
Inherited: yes | ||||||
|
@@ -5612,9 +5612,87 @@ Selecting How to Wrap: the 'text-wrap-style' property</h3> | |||||
<dt><dfn>pretty</dfn> | ||||||
<dd> | ||||||
Specifies the UA <em>should</em> bias for better layout over speed, | ||||||
and is expected to consider multiple lines, | ||||||
and is expected to consider multiple lines | ||||||
when making break decisions. | ||||||
Otherwise equivalent to ''text-wrap-style/auto'', | ||||||
Otherwise equivalent to ''text-wrap-style/auto''. | ||||||
|
||||||
The user agent may among other things | ||||||
attempt to avoid excessively short last lines, | ||||||
similarly to ''reduce-orphans'', | ||||||
but it should also improve the layout in more ways. | ||||||
The precise set of improvements is user agent dependent, | ||||||
and may include things such as: | ||||||
reducing the variation in length between lines; | ||||||
avoiding <a href="https://en.wikipedia.org/wiki/River_(typography)">typographic rivers</a>; | ||||||
prioritizing different classes of [=soft wrap opportunities=], [=hyphenation opportunities=], or [=justification opportunities=]; | ||||||
avoiding hyphenation on too many consecutive lines… | ||||||
|
||||||
<div class=advisement> | ||||||
The necessary computations may be expensive, | ||||||
especially when applied to large amounts of text. | ||||||
Authors are encouraged to asses the impact on performance | ||||||
astearns marked this conversation as resolved.
Show resolved
Hide resolved
frivoal marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
when using ''text-wrap-style: pretty'', | ||||||
and possibly use it selectively where it matters most. | ||||||
</div> | ||||||
|
||||||
<dt><dfn>reduce-orphans</dfn> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc: @astearns The key is to find a term that indicates that the value is about getting rid of orphans, but not in all circumstances, and not at any cost. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’m OK going with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If they don't think about too much, probably. But if you show them examples of cases where it would be bad to do so, and it doesn't do so, I suspect they'll be happy with the result, since forcibly doing it would be ugly. |
||||||
<dd> | ||||||
Specifies the UA <em>should</em> avoid excessively short last lines, | ||||||
and is expected to consider more than one line | ||||||
when making break decisions. | ||||||
astearns marked this conversation as resolved.
Show resolved
Hide resolved
frivoal marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
The user agent may decide against improving the last line | ||||||
when it would make some prior line(s) substantially unbalanced. | ||||||
The user agent should not attempt to improve other aspects of the layout | ||||||
beyond what ''text-wrap-style/auto'' | ||||||
if that comes at a significant performance cost. | ||||||
frivoal marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
Note: In western typography, an “orphan” typically refers to a single word on the last line of a paragraph. | ||||||
astearns marked this conversation as resolved.
Show resolved
Hide resolved
frivoal marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
However, not all languages or writing systems wrap lines at word boundaries, | ||||||
and even in languages that do, | ||||||
a few very short words on the last line may still be undesirable, | ||||||
especially if the available inline space is long. | ||||||
This specification does not therefore strictly define | ||||||
lines to be too short only when they are composed a single word, | ||||||
and lets the user agent be the judge of what is excessively short. | ||||||
|
||||||
Note: See also the 'orphans' property for control over fragmentation | ||||||
and the other typographic meaning of “orphans”. | ||||||
|
||||||
<div class=example> | ||||||
For instance, with the given line length, the following test would be wrapped with a single word on the last line, | ||||||
which could be judged too short. | ||||||
<pre lang=grc style="border: solid lightgray 8px; border-bottom: none; border-top: none; width: 45ch;"> | ||||||
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα | ||||||
πολλὰ πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον | ||||||
ἔπερσεν. | ||||||
</pre> | ||||||
Applying ''text-wrap-style: reduce-orphans'' could yield something like this instead, | ||||||
which is arguably more pleasing: | ||||||
<pre lang=grc style="border: solid lightgray 8px; border-bottom: none; border-top: none; width: 45ch;"> | ||||||
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς | ||||||
μάλα πολλὰ πλάγχθη, ἐπεὶ Τροίης ἱερὸν | ||||||
πτολίεθρον ἔπερσεν. | ||||||
</pre> | ||||||
</div> | ||||||
<div class=example> | ||||||
However, the following fragment is more vexing: | ||||||
<pre style="border: solid lightgray 8px; border-bottom: none; border-top: none; width: 17ch;"> | ||||||
Circumnavigating | ||||||
the Mississippi | ||||||
river | ||||||
</pre> | ||||||
An attempt to make the last line less short by wrapping the previous line earlier would result in the following: | ||||||
<pre style="border: solid lightgray 8px; border-bottom: none; border-top: none; width: 17ch;"> | ||||||
Circumnavigating | ||||||
the | ||||||
Mississippi river | ||||||
</pre> | ||||||
While the last line would indeed no longer be short, | ||||||
the penultimate line would be unsightly. | ||||||
In such cases, user agents are expected | ||||||
to prefer the first rendering | ||||||
despite ''text-wrap-style: reduce-orphans'' being set. | ||||||
</div> | ||||||
</dl> | ||||||
|
||||||
<!-- add a sample prioritization algorithm --> | ||||||
|
@@ -5626,10 +5704,12 @@ Selecting How to Wrap: the 'text-wrap-style' property</h3> | |||||
UAs can experiment with better line breaking algorithms | ||||||
with this default value, | ||||||
but as optimal results often take more time, | ||||||
''text-wrap-style/pretty'' is offered as an opt-in | ||||||
''text-wrap-style/pretty'' and ''reduce-orphans'' are offered as opt-ins | ||||||
to take more time for better results. | ||||||
The ''text-wrap-style/pretty'' value is intended for body text, | ||||||
where the last line is expected to be a bit shorter than the average line; | ||||||
Both values are intended for body text, | ||||||
where the last line is expected to be a bit shorter than the average line, | ||||||
astearns marked this conversation as resolved.
Show resolved
Hide resolved
astearns marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
but ''reduce orphans'' aims to avoid excessively short last lines and to stay performant, | ||||||
frivoal marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
while ''pretty'' can sacrifice more speed in pursuit of even better layout; | ||||||
the ''text-wrap-style/balance'' value is intended for titles and captions, | ||||||
where equal-length lines of text tend to be preferred; | ||||||
and the ''text-wrap-style/stable'' is intended for sections that are, | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.