@@ -1635,7 +1635,9 @@ Text Processing</h3>
16351635 </wpt>
16361636
16371637 <li> If 'white-space' is set to ''pre-wrap'' ,
1638- the UA must [=conditionally hang=] this sequence.
1638+ the UA must (unconditionally) [=hang=] this sequence,
1639+ unless the sequence is followed by a [=forced line break=] ,
1640+ in which case it must [=conditionally hang=] the sequence is instead.
16391641 It may also visually collapse the character advance widths
16401642 of any that would otherwise overflow.
16411643
@@ -1712,29 +1714,91 @@ Text Processing</h3>
17121714 </ol>
17131715
17141716 <div class=example>
1715- This example illustrates the consequence of [=hanging=] white space
1716- at the end of the line
1717- on text alignment.
1717+ This example shows that [=conditionally hanging=] white space
1718+ at the end of lines with forced breaks
1719+ provides symmetry with the start of the line.
1720+ An underline is added to help visualize the spaces.
17181721 <pre><code class=lang-css>
17191722 p {
17201723 white-space: pre-wrap;
1721- text-align: end;
1722- width: 20ch;
1724+ width: 5ch;
17231725 border: solid 1px;
1726+ font-family: monospace;
1727+ text-align: center;
17241728 }</code></pre>
17251729 <pre><code class=lang-markup>
1726- <p>Lorem ipsum </p>
1730+ <p> 0 </p>
17271731 </code></pre>
17281732
1729- As the [=preserved=] [=spaces=] at the end of the line must [=hang=] ,
1733+ The sample above would be rendered as follows:
1734+ <div style="word-wrap: normal; font-size: 2em; font-family: monospace; width: 5ch; border: solid 1px; white-space: pre;"> <span style="text-decoration: underline; text-decoration: underline orange"> 0 </span> </div>
1735+
1736+ Since the final [=space=] is before a forced line break
1737+ and does not overflow,
1738+ it does not hang,
1739+ and centering works as expected.
1740+ </div>
1741+
1742+ <div class=example>
1743+ This example illustrates the difference
1744+ between [=hanging=] [=spaces=]
1745+ at the end of lines without forced breaks,
1746+ and [=conditionally hanging=] them at the end of lines with forced breaks.
1747+ An underline is added to help visualize the [=spaces=] .
1748+ <pre><code class=lang-css>
1749+ p {
1750+ white-space: pre-wrap;
1751+ width: 3ch;
1752+ border: solid 1px;
1753+ font-family: monospace;
1754+ }</code></pre>
1755+ <pre><code class=lang-markup>
1756+ <p> 0 0 0 0 </p>
1757+ </code></pre>
1758+
1759+ The sample above would be rendered as follows:
1760+ <div style="word-wrap: normal; font-size: 2em; font-family: monospace; width: 3ch; border: solid 1px; white-space: pre; text-decoration: underline; text-decoration: underline orange"> 0 <br> 0 0 <br> 0 </div>
1761+
1762+ If <code class=lang-css> p { text-align: right; }</code> was added,
1763+ the result would be as follows:
1764+ <div style="word-wrap: normal; font-size: 2em; font-family: monospace; width: 3ch; border: solid 1px; white-space: pre;"> <span style="text-decoration: underline; text-decoration: underline orange"> 0 </span><br><span style="text-decoration: underline; text-decoration: underline orange"> 0 0 </span><br> <span style="text-decoration: underline; text-decoration: underline orange"> 0 </span></div>
1765+
1766+ As the [=preserved=] [=spaces=] at the end of lines without a forced break must [=hang=] ,
17301767 they are not considered when placing the rest of the line during text alignment.
17311768 When aligning towards the end,
17321769 this means any such [=spaces=] will overflow,
17331770 and will not prevent the rest of the line's content from being flush with the edge of the line.
1734- The sample above would therefore be rendered as follows:
1735- <pre class=output style="width: 20ch; border: solid 1px; text-align: end;">
1736- Lorem ipsum
1737- </pre>
1771+ On the other hand,
1772+ preserved spaces at the end of a line <em> with</em> a forced break
1773+ [=conditionally hang=] .
1774+ Since the space at the end of the last line would not overflow in this example,
1775+ it does not [=hang=]
1776+ and therefore is considered during text alignment.
1777+ </div>
1778+
1779+ <div class=example>
1780+ In the following example,
1781+ there is not enough room on any line to fit the end-of-line spaces,
1782+ so they [=hang=] on all lines:
1783+ the one on the line without a forced break because it must,
1784+ as well as the one on the line with a forced break,
1785+ because it [=conditionally hangs=] and overflows.
1786+ An underline is added to help visualize the spaces.
1787+ <pre><code class=lang-css>
1788+ p {
1789+ white-space: pre-wrap;
1790+ width: 3ch;
1791+ border: solid 1px;
1792+ font-family: monospace;
1793+ }</code></pre>
1794+ <pre><code class=lang-markup>
1795+ <p>0 0 0 0 </p>
1796+ </code></pre>
1797+ <div style="word-wrap: normal; font-size: 2em; font-family: monospace; width: 3ch; border: solid 1px; white-space: pre; text-decoration: underline; text-decoration: underline orange"> 0 0 <br> 0 0 </div>
1798+
1799+ The last line is not wrapped before the last <code> 0</code>
1800+ because characters that [=conditionally hang=] are not considered
1801+ when measuring the line’s contents for fit.
17381802 </div>
17391803
17401804 <h3 id="tab-size-property" caniuse="css3-tabsize" oldids="tab-size">
0 commit comments