Skip to content

Commit 310083b

Browse files
committed
[css-text-4] Example for 'discard-inner'
1 parent 4b5444f commit 310083b

1 file changed

Lines changed: 63 additions & 1 deletion

File tree

css-text-4/Overview.bs

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2614,13 +2614,75 @@ White Space Trimming: the 'white-space-trim' property</h3>
26142614
can change where [=line breaking opportunities=] occur in the text.
26152615

26162616
<div class="example">
2617-
<p>The following style rules render DT elements as a comma-separated list:
2617+
<p>The following style rules render DT elements as a comma-separated list,
2618+
even if they are coded on separate lines of the source document:
26182619
<pre>
26192620
dt { display: inline; }
26202621
dt + dt:before { content: ", "; white-space-trim: discard-before; }
26212622
</pre>
26222623
</div>
26232624

2625+
<div class="example">
2626+
<p>The following style rule removes source-formatting white space
2627+
adjacent to the opening/closing tags of a preformatted block,
2628+
but not any indentation or interleaved white space
2629+
applied to the actual contents of the element:
2630+
<pre>
2631+
pre { white-space: pre; white-space-trim: discard-inner; }
2632+
</pre>
2633+
This results in the following two source-code snippets:
2634+
<div style="display: flex; flex-flow: wrap; justify-content: space-around">
2635+
<xmp highlight="html">
2636+
<pre>
2637+
2638+
some
2639+
preformatted
2640+
2641+
text
2642+
2643+
</pre>
2644+
</xmp>
2645+
<xmp highlight="html">
2646+
<pre> some
2647+
preformatted
2648+
2649+
text</pre>
2650+
</xmp>
2651+
</div>
2652+
rendering identically as:
2653+
<pre class="output" style="margin-inline: auto">
2654+
some
2655+
preformatted
2656+
2657+
text</pre>
2658+
2659+
If instead we apply it to an inline element:
2660+
<pre>
2661+
span { white-space: normal; white-space-trim: discard-inner; }
2662+
</pre>
2663+
<div style="display: flex; flex-flow: wrap; justify-content: space-around">
2664+
<xmp highlight="html">
2665+
start[<span>
2666+
2667+
some
2668+
inline
2669+
text
2670+
2671+
</span>]end
2672+
</xmp>
2673+
<xmp highlight="html">
2674+
start[<span> some
2675+
inline
2676+
text</span>]end
2677+
</xmp>
2678+
</div>
2679+
this directs the UA to discard <em>all</em> of the leading/trailing white space
2680+
before the actual contents of the element:
2681+
<pre class="output" style="margin-inline: auto">
2682+
start[some inline text]end
2683+
</pre>
2684+
</div>
2685+
26242686
White space processing for 'white-space-trim'
26252687
takes place before [[#white-space-phase-1]].
26262688

0 commit comments

Comments
 (0)