Skip to content

Commit 6736f55

Browse files
committed
[css-text-3] Provide more extensive examples
1 parent fe625c2 commit 6736f55

File tree

1 file changed

+60
-14
lines changed

1 file changed

+60
-14
lines changed

css-text-3/Overview.bs

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,42 +1709,88 @@ Text Processing</h3>
17091709
</ol>
17101710

17111711
<div class=example>
1712-
This example illustrates the consequence of [=hanging=] white space
1712+
This example shows that not [=hanging=] white space
1713+
at the end of lines with forced breaks
1714+
provides symmetry with the start of the line.
1715+
An underline is added to help visualize the spaces.
1716+
<pre><code class=lang-css>
1717+
p {
1718+
white-space: pre-wrap;
1719+
width: 5ch;
1720+
border: solid 1px;
1721+
font-family: monospace;
1722+
text-align: center;
1723+
}</code></pre>
1724+
<pre><code class=lang-markup>
1725+
&lt;p> 0 &lt;/p>
1726+
</code></pre>
1727+
1728+
The sample above would be rendered as follows:
1729+
<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>
1730+
1731+
Since the final space is before a forced line break
1732+
it does not hang,
1733+
and centering works as expected.
1734+
</div>
1735+
1736+
<div class=example>
1737+
This example illustrates the difference
1738+
between [=hanging=] white space
17131739
at the end of lines without forced breaks,
1714-
and of not hanging at the end of lines with forced breaks.
1740+
and not hanging them at the end of lines with forced breaks.
17151741
An underline is added to help visualize the spaces.
17161742
<pre><code class=lang-css>
17171743
p {
17181744
white-space: pre-wrap;
17191745
width: 3ch;
17201746
border: solid 1px;
17211747
font-family: monospace;
1722-
text-decoration: underline orange;
17231748
}</code></pre>
17241749
<pre><code class=lang-markup>
1725-
&lt;p>0 0 0 0 &lt;/p>
1750+
&lt;p> 0 0 0 0 &lt;/p>
17261751
</code></pre>
17271752

17281753
The sample above would be rendered as follows:
1729-
<div style="font-size: 2em; font-family: monospace; width: 3ch; border: solid 1px; white-space: pre; text-decoration: underline orange">0 0 <br>0 <br>0 </div>
1754+
<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>
17301755

1731-
Because the last [=space=] is before a forced break,
1732-
and therefore does not hang,
1733-
a wrapping opportunity must be found earlier in the line,
1734-
introducing a break before the last “0”.
1735-
1736-
Additionally, if <code class=lang-css>p { text-align: right; }</code> was added,
1756+
If <code class=lang-css>p { text-align: right; }</code> was added,
17371757
the result would be as follows:
1738-
<div style="font-size: 2em; font-family: monospace; width: 3ch; border: solid 1px; white-space: pre;"><span style="text-decoration: underline orange">0 0 </span><br>&nbsp;&nbsp;<span style="text-decoration: underline orange">0 </span><br> <span style="text-decoration: underline orange">0 </span></div>
1758+
<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>
17391759

17401760
As the [=preserved=] [=spaces=] at the end of lines without a forced break must [=hang=],
17411761
they are not considered when placing the rest of the line during text alignment.
17421762
When aligning towards the end,
17431763
this means any such [=spaces=] will overflow,
17441764
and will not prevent the rest of the line's content from being flush with the edge of the line.
17451765
On the other hand,
1746-
preserved spaces at the end of a line <em>with</em> a forced break do not hang,
1747-
and therefore are considered during text alignment.
1766+
preserved spaces at the end of a line <em>with</em> a forced break
1767+
do not hang.
1768+
Therefore, the space at the end of the last line in this example
1769+
does not [=hang=]
1770+
and is considered during text alignment.
1771+
</div>
1772+
1773+
<div class=example>
1774+
In the following example,
1775+
there is not enough room on any line to fit the end-of-line spaces,
1776+
so they [=hang=] on the line without forced break.
1777+
The last space,
1778+
if placed on the second line,
1779+
would overflow, and is not allowed to hang.
1780+
Therefore, it causes a soft wrap break earlier in the line,
1781+
before the last <code>0</code>.
1782+
An underline is added to help visualize the spaces.
1783+
<pre><code class=lang-css>
1784+
p {
1785+
white-space: pre-wrap;
1786+
width: 3ch;
1787+
border: solid 1px;
1788+
font-family: monospace;
1789+
}</code></pre>
1790+
<pre><code class=lang-markup>
1791+
&lt;p>0 0 0 0 &lt;/p>
1792+
</code></pre>
1793+
<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 <br>0 </div>
17481794
</div>
17491795

17501796
<h3 id="tab-size-property" caniuse="css3-tabsize" oldids="tab-size">

0 commit comments

Comments
 (0)