Skip to content

Commit 7180f92

Browse files
committed
[css-pseudo-4] Improve markup
1 parent 933618c commit 7180f92

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

css-pseudo-4/Overview.bs

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The ::first-line pseudo-element</h3>
6363
The rule below means
6464
“change the letters of the first line of every <code>p</code> element to uppercase”:
6565

66-
<pre>p::first-line { text-transform: uppercase }</pre>
66+
<pre class="lang-css">p::first-line { text-transform: uppercase }</pre>
6767

6868
The selector ''p::first-line''
6969
does not match any real document element.
@@ -78,7 +78,7 @@ The ::first-line pseudo-element</h3>
7878
<div class="example" id="first-line-example">
7979
For example, given an ordinary HTML [[HTML5]] paragraph such as:
8080

81-
<pre>
81+
<pre class="lang-markup">
8282
&lt;P&gt;This is a somewhat long HTML paragraph
8383
that will be broken into several lines.
8484
The first line will be styled
@@ -90,7 +90,7 @@ The ::first-line pseudo-element</h3>
9090
Depending on the width of the element,
9191
its lines might be broken as follows:
9292

93-
<pre>
93+
<pre class="figure">
9494
THIS IS A SOMEWHAT LONG HTML PARAGRAPH THAT
9595
will be broken into several lines. The
9696
first line will be by the ‘::first-line’
@@ -100,7 +100,7 @@ The ::first-line pseudo-element</h3>
100100

101101
or alternately as follows:
102102

103-
<pre>
103+
<pre class="figure">
104104
THIS IS A SOMEWHAT LONG
105105
HTML paragraph that will
106106
be broken into several
@@ -133,15 +133,15 @@ Finding the First Formatted Line</h4>
133133

134134
Note: The [=first formatted line=] can be an empty line.
135135
For example, the first line of the <code>p</code> in
136-
<code>&lt;p&gt;&lt;br&gt;First&hellip;</code>
136+
<code class="lang-markup">&lt;p&gt;&lt;br&gt;First&hellip;</code>
137137
doesn't contain any letters.
138138
Thus the word “First” is not on the first formatted line,
139139
and will not be affected by ''p::first-line''.
140140

141141
Note: The first line of a [=block container=]
142142
that does not participate in a [=block formatting context=]
143143
cannot be the first formatted line of an ancestor element.
144-
Thus, in <code>&lt;DIV&gt;&lt;P STYLE="display: inline-block"&gt;Hello&lt;BR&gt;Goodbye&lt;/P&gt; etcetera&lt;/DIV&gt;</code>
144+
Thus, in <code class="lang-markup">&lt;DIV&gt;&lt;P STYLE="display: inline-block"&gt;Hello&lt;BR&gt;Goodbye&lt;/P&gt; etcetera&lt;/DIV&gt;</code>
145145
the first formatted line of the <code>DIV</code> is not the line “Hello”,
146146
but rather the (otherwise empty) line that contains that entire inline block.
147147

@@ -151,7 +151,7 @@ Finding the First Formatted Line</h4>
151151

152152
<div class="example">
153153
Consider the following markup:
154-
<pre>
154+
<pre class="lang-markup">
155155
&lt;DIV&gt;
156156
&lt;P&gt;First paragraph&lt;/P&gt;
157157
&lt;P&gt;Second paragraph&lt;/P&gt;
@@ -162,7 +162,7 @@ Finding the First Formatted Line</h4>
162162
the elements’ ''::first-line'' pseudo elements,
163163
it would be something like:
164164

165-
<pre>
165+
<pre class="lang-markup">
166166
&lt;DIV&gt;
167167
&lt;P&gt;&lt;DIV::first-line&gt;&lt;P::first-line&gt;First paragraph&lt;/P::first-line&gt;&lt;/DIV::first-line&gt;&lt;/P&gt;
168168
&lt;P&gt;&lt;P::first-line&gt;Second paragraph&lt;/P::first-line&gt;&lt;/P&gt;
@@ -220,7 +220,7 @@ Inheritance and the ''::first-line'' Pseudo-element</h4>
220220
Consider the <a href="#first-line-example">earlier example</a>;
221221
in case of the first rendering, the fictional tag sequence would be:
222222

223-
<pre>
223+
<pre class="lang-markup">
224224
&lt;P&gt;<strong>&lt;p::first-line></strong>This is a somewhat long HTML paragraph
225225
that<strong>&lt;/p::first-line></strong> will be broken into several lines.
226226
The first line will be styled
@@ -231,7 +231,7 @@ Inheritance and the ''::first-line'' Pseudo-element</h4>
231231

232232
And in the case of the second rendering:
233233

234-
<pre>
234+
<pre class="lang-markup">
235235
&lt;P&gt;<strong>&lt;p::first-line></strong>This is a somewhat long<strong>&lt;/p::first-line></strong> HTML paragraph
236236
that will be broken into several lines.
237237
The first line will be styled
@@ -250,7 +250,7 @@ Inheritance and the ''::first-line'' Pseudo-element</h4>
250250
Suppose we mark up the earlier example
251251
with a <code>span</code> element encompassing the first sentence:
252252

253-
<pre>
253+
<pre class="lang-markup">
254254
&lt;P&gt;<strong>&lt;span></strong>This is a somewhat long HTML paragraph
255255
that will be broken into several lines.<strong>&lt;/span></strong>
256256
The first line will be styled
@@ -262,8 +262,8 @@ Inheritance and the ''::first-line'' Pseudo-element</h4>
262262
The effect of the first rendering
263263
would be similar to the following [=fictional tag sequence=]:
264264

265-
<pre>
266-
&lt;P&lt;P&gt;<strong>&lt;p::first-line>&gt;&lt;span></strong>This is a somewhat long HTML paragraph
265+
<pre class="lang-markup">
266+
&lt;P&lt;P&gt;<strong>&lt;p::first-line>&lt;span></strong>This is a somewhat long HTML paragraph
267267
that<strong>&lt;/span>&lt;/P&gt;&lt;p::first-line>&lt;span></strong> will be broken into several lines.<strong>&lt;/span></strong>
268268
The first line will be styled
269269
by the ‘::first-line’ pseudo-element.
@@ -289,8 +289,7 @@ The ::first-letter pseudo-element</h3>
289289
on every paragraph following a level-2 header,
290290
using the 'initial-letter' property defined in [[CSS-INLINE-3]]:
291291

292-
<pre>h2 + p::first-letter { initial-letter: 2; }
293-
</pre>
292+
<pre class="lang-css">h2 + p::first-letter { initial-letter: 2; }</pre>
294293
</div>
295294

296295
As explained in [[!CSS-TEXT-3]],
@@ -338,7 +337,7 @@ Finding the First Letter Text</h4>
338337

339338
<div class="example">
340339
Example:
341-
After the rule ''p::before {content: "Note: "}'', the
340+
After the rule <code class="lang-css">p::before {content: "Note: "}</code>, the
342341
selector ''p::first-letter'' matches the "N" of "Note".
343342
</div>
344343

@@ -349,7 +348,7 @@ Finding the First Letter Text</h4>
349348
Note: When the [=first formatted line=] is empty,
350349
''::first-letter'' will not match anything.
351350
For example, in this HTML fragment:
352-
<code>&lt;p&gt;&lt;br&gt;First...</code>
351+
<code class="lang-markup">&lt;p&gt;&lt;br&gt;First...</code>
353352
the first line doesn't contain any letters,
354353
so ''::first-letter'' doesn't match anything.
355354
In particular, it does not match the “F” of “First”,
@@ -359,7 +358,7 @@ Finding the First Letter Text</h4>
359358
the [=first-letter text=] of a [=block container=]
360359
that does not participate in a [=block formatting context=]
361360
cannot be the [=first-letter text=] of an ancestor element.
362-
Thus, in <code>&lt;DIV&gt;&lt;P STYLE="display: inline-block"&gt;Hello&lt;BR&gt;Goodbye&lt;/P&gt; etcetera&lt;/DIV&gt;</code>
361+
Thus, in <code class="lang-markup">&lt;DIV&gt;&lt;P STYLE="display: inline-block"&gt;Hello&lt;BR&gt;Goodbye&lt;/P&gt; etcetera&lt;/DIV&gt;</code>
363362
the first letter of the <code>DIV</code> is not the letter “H”.
364363
In fact, the <code>DIV</code> doesn't have a first letter,
365364
as its [=first formatted line=] contains no content besides the inline block.
@@ -370,14 +369,14 @@ Inheritance and Box Tree Structure of the ''::first-letter'' Pseudo-element</h4>
370369
The ''::first-letter'' pseudo-element is wrapped
371370
immediately around the [=first-letter text=] it represents,
372371
even if that text is in a descendant.
373-
When a [=first-letter text=] is represented by multiple ''::first-letter" pseudo-elements,
372+
When a [=first-letter text=] is represented by multiple ''::first-letter'' pseudo-elements,
374373
they are nested in the same order as their [=originating elements=].
375374
[=Inheritance=] behaves accordingly.
376375

377376
<div class="example">
378377
Consider the following markup:
379378

380-
<pre>
379+
<pre class="lang-markup">
381380
&lt;div&gt;
382381
&lt;p&gt;&lt;span&gt;The first few words&lt;/span>
383382
and the rest of the paragraph.
@@ -388,7 +387,7 @@ Inheritance and Box Tree Structure of the ''::first-letter'' Pseudo-element</h4>
388387
to represent the elements’ ''::first-letter'' pseudo-elements,
389388
it would be something like:
390389

391-
<pre>
390+
<pre class="lang-markup">
392391
&lt;div&gt;
393392
&lt;p&gt;&lt;span&gt;<strong>&lt;div::first-letter&gt;&lt;p::first-letter&gt;</strong>T<strong>&lt;/&hellip;&gt;&lt;/&hellip;&gt;</strong>he first few words&lt;/span>
394393
and the rest of the paragraph.
@@ -398,7 +397,7 @@ Inheritance and Box Tree Structure of the ''::first-letter'' Pseudo-element</h4>
398397

399398
If the characters that would form the [=first-letter text=]
400399
are not all in the same element
401-
(as the <code>‘T</code> in <code>&lt;p&gt;‘&lt;em&gt;T...</code>),
400+
(as the <code>‘T</code> in <code class="lang-css">&lt;p&gt;‘&lt;em&gt;T...</code>),
402401
the user agent may create a ''::first-letter'' pseudo-element
403402
from one of the elements, or all elements,
404403
or simply not create a pseudo-element.
@@ -646,13 +645,13 @@ Cascading and Per-Element Highlight Styles</h3>
646645

647646
<div class="example">
648647
For example, if the following rules were applied:
649-
<pre>
648+
<pre class="lang-css">
650649
p::selection { color: yellow; background: green; }
651650
p > em::selection { color: orange; }
652651
em::selection { color: red; }
653652
</pre>
654653
to the following markup:
655-
<pre>
654+
<pre class="lang-markup">
656655
&lt;p>Highlight this &lt;em>and this&lt;/em>.&lt;/p>
657656
</pre>
658657
The selection highlight would be green throughout,
@@ -674,12 +673,12 @@ Cascading and Per-Element Highlight Styles</h3>
674673

675674
<div class="example">
676675
For example, if an author specified
677-
<pre>
676+
<pre class="lang-css">
678677
::selection { background: blue; }
679678
p.warning::selection { background: red; }
680679
</pre>
681680
and the document included
682-
<pre>
681+
<pre class="lang-markup">
683682
&lt;p class="warning">Some &lt;strong>very important information&lt;/strong>&lt;/p>
684683
</pre>
685684
The highlight would be blue over “very important information”
@@ -688,7 +687,7 @@ Cascading and Per-Element Highlight Styles</h3>
688687
(Remember that ''*'' is implied when a tag selector is missing.)
689688
The style rules that would give the intended behavior
690689
(red highlight within <code>p.warning</code>, blue elsewhere) are
691-
<pre>
690+
<pre class="lang-css">
692691
:root::selection { background: blue; }
693692
p.warning::selection { background: red; }
694693
</pre>
@@ -833,7 +832,7 @@ Generated Content Pseudo-elements: ''::before'' and ''::after''</h3>
833832
before the content of every <code>&lt;p></code> element
834833
whose <code>class</code> attribute has the value <code>note</code>:
835834

836-
<pre>p.note::before { content: "Note: " }</pre>
835+
<pre class="lang-css">p.note::before { content: "Note: " }</pre>
837836

838837
Since the initial value of 'display' is ''display/inline'',
839838
this will generate an inline box.
@@ -920,7 +919,7 @@ File Selector Button: the ''::file-selector-button'' pseudo-element</h3>
920919
For example, the following example should show a green border around the
921920
file selector button:
922921

923-
<pre>::file-selector-button { border: 3px solid green }</pre>
922+
<pre class="lang-css">::file-selector-button { border: 3px solid green }</pre>
924923
</div>
925924

926925
<h2 id="interactions">

0 commit comments

Comments
 (0)