@@ -12,7 +12,8 @@ Editor: Daniel Glazman, Disruptive Innovations
12
12
Editor : fantasai, Invited Expert, http://fantasai.inkedblade.net/contact
13
13
Editor : Alan Stearns, Adobe Systems Inc., stearns@adobe.com
14
14
Abstract : This CSS module defines pseudo-elements, abstract elements that represent portions of the CSS render tree that can be selected and styled.
15
- Ignored Terms : typographic letter unit, Unicode general category, initial-letter
15
+ Ignored Terms : initial-letter
16
+ Link Defaults : css-color-3 (property) color
16
17
</pre>
17
18
18
19
<h2 id="intro">Introduction</h2>
@@ -318,7 +319,7 @@ Finding the First Letter</h4>
318
319
Styling the ''::first-letter'' Pseudo-element</h4>
319
320
320
321
In CSS a ::first-letter pseudo-element is similar to an inline-level element
321
- if its 'float' property is ''none'' ;
322
+ if its 'float' property is ''float/ none'' ;
322
323
otherwise, it is similar to a floated element.
323
324
The following properties that apply to ''::first-letter'' pseudo-elements:
324
325
@@ -416,64 +417,38 @@ Styling the ''::first-letter'' Pseudo-element</h4>
416
417
</div>
417
418
418
419
<h2 id="highlight-pseudos">
419
- Highlight Range Pseudo-element: ''::selection''</h2>
420
+ Styling Highlights: the ''::selection'', ''::spelling-error'', and ''::grammar-error'' pseudo-elements </h2>
420
421
421
- The <dfn>::selection</dfn> pseudo-element represents
422
- the portion of a document that has been highlighted by the user.
423
- This also applies, for example, to selected text within an editable text field.
422
+ The <dfn>highlight pseudo-elements</dfn>
423
+ represent portions of a document that have been highlighted in some way.
424
424
425
- Issue: We want to add other types of selections, such as spelling-error highlights.
426
-
427
- Issue: Active vs. inactive selections are often styled differently. Currently no way to distinguish.
428
-
429
- <p> The <dfn>root highlight</dfn> is a multi-piece overlay
430
- over the entire tree,
431
- portions of which are selected and correspond to the ''::selection'' pseudo-element.
432
- Each box owns the piece of of the overlay corresponding to any text or replaced content
433
- directly contained by the box.
434
- For text, the corresponding overlay must cover at least the entire em box
435
- and may extend further above/below the em box to the line box edges.
436
- Spacing between two characters may also be part of the overlay,
437
- in which case it belongs to the innermost element that contains both characters
438
- and is selected when both characters are selected
439
- For replaced content, the associated overlay must cover at least the entire replaced object,
440
- and may extend outward to include the element's entire content box.
441
- The overlay may also include other other areas within the border-box of an element;
442
- in this case, those areas belong to the innermost such element that contains the area.
443
-
444
- Issue: See
445
- <a href="http://lists.w3.org/Archives/Public/www-style/2008Nov/0022.html">F2F minutes</a> ,
446
- <a href="http://lists.w3.org/Archives/Public/www-style/2008Oct/0268.html">dbaron's message</a> ,
447
- <a href="http://lists.w3.org/Archives/Public/www-style/2010May/0247.html">Daniel's thread</a> ,
448
- <a href="http://lists.w3.org/Archives/Public/www-style/2010May/0261.html">Gecko notes</a> ,
449
- <a href="http://lists.w3.org/Archives/Public/www-style/2010May/0366.html">Opera notes</a> ,
450
- <a href="http://lists.w3.org/Archives/Public/www-style/2010May/0280.html">Webkit notes</a>
451
-
452
- Each element draws its own portion of the highlighted overlay,
453
- which receives the styles specified by the ''::selection'' pseudo-element styles
454
- for which it or one of its ancestors is the <i> originating element</i> .
455
- When multiple styles conflict,
456
- the winning style is the one belonging to the innermost element
457
- after cascading.
425
+ <dl export>
426
+ <dt> <dfn>::selection</dfn>
427
+ <dd>
428
+ The <a>::selection</a> pseudo-element represents
429
+ the portion of a document that has been highlighted by the user.
430
+ This also applies, for example, to selected text within an editable text field.
431
+
432
+ Issue: Active vs. inactive selections are often styled differently. Currently no way to distinguish.
458
433
459
- Issue: This could alternately be described in terms of inheritance.
460
- So, how do we want ''inherit'' to behave here?
461
- Should it inherit from the parent ''::selection''
462
- or the <i> originating element</i> ?
463
- Opera does the former, Gecko/Blink the latter.
434
+ <dt> <dfn>::spelling-error</dfn>
435
+ <dd>
436
+ The <a>::spelling-error</a> pseudo-element represents
437
+ a portion of text that has been flagged by the user agent as misspelled.
438
+
439
+ <dt> <dfn>::grammar-error</dfn>
440
+ <dd>
441
+ The <a>::grammar-error</a> pseudo-element represents
442
+ a portion of text that has been flagged by the user agent as grammatically incorrect.
443
+ </dl>
464
444
465
- <p class="advisement">
466
- Authors wanting multiple selections styles should use
467
- <strong> '':root::selection'' </strong>
468
- for their document-wide selection style,
469
- since this will allow clean overriding in descendants.
470
- (''::selection'' alone would apply to every element in the tree,
471
- overriding the more specific styles of any ancestors.)
445
+ Note: A future level of CSS may introduce ways to create
446
+ custom highlight pseudo-elements.
472
447
473
448
<h3 id="highlight-styling">
474
- Styling Highlighted Ranges </h3>
449
+ Styling Highlighted Content </h3>
475
450
476
- The following properties apply to ''::selection'' pseudo-elements:
451
+ The following properties apply to the <a>highlight pseudo-elements</a> :
477
452
478
453
<ul>
479
454
<li> 'color'
@@ -494,10 +469,9 @@ Styling Highlighted Ranges</h3>
494
469
If 'color' is not specified, the text (and text decoration)'s
495
470
unselected color must be used for the highlight.
496
471
(As usual, the initial 'background-color' is ''transparent'' .)
497
-
498
472
Issue: Can we reuse ''currentColor'' for this, now that it computes to itself?
499
473
500
- The UA should use the OS-default selection color
474
+ The UA should use the OS-default highlight colors
501
475
when neither 'color' nor 'background-color' has been specified by the author.
502
476
503
477
Note: This paired-cascading behavior
@@ -506,6 +480,96 @@ Styling Highlighted Ranges</h3>
506
480
However it has been interoperably implemented in browsers
507
481
and is thus probably a Web-compatibility requirement.
508
482
483
+ The 'color' property specifies the color of both the text
484
+ and all line decorations (underline, overline, line-through)
485
+ applied to the text.
486
+ Note: Because 'text-emphasis-color' defaults to ''currrentColor'' ,
487
+ it will by default also set the color of the the emphasis marks.
488
+
489
+ <h3 id=highlight-bounds>
490
+ Area of the Highlight</h3>
491
+
492
+ <p> For each instance of highlighting
493
+ there exists a <dfn>root highlight overlay</dfn>
494
+ which is a tesselated overlay
495
+ over the entire tree,
496
+ the actively-highlighted portions of which are represented
497
+ by the corresponding <a>highlight pseudo-element</a> .
498
+ The ''::selection'' overlay is drawn
499
+ over the ''::spelling-error'' overlay
500
+ which is drawn over the ''::grammar-error'' overlay.
501
+
502
+
503
+ Each box owns a piece of the overlay corresponding to any text or replaced content
504
+ directly contained by the box.
505
+
506
+ <ul>
507
+ <li>
508
+ For text, the corresponding overlay must cover at least the entire em box
509
+ and may extend further above/below the em box to the line box edges.
510
+ Spacing between two characters may also be part of the overlay,
511
+ in which case it belongs to the innermost element that contains both characters
512
+ and is selected when both characters are selected.
513
+ <li>
514
+ For replaced content, the associated overlay must cover at least the entire replaced object,
515
+ and may extend outward to include the element's entire content box.
516
+ <li>
517
+ The overlay may also include other other areas within the border-box of an element;
518
+ in this case, those areas belong to the innermost such element that contains the area.
519
+ </ul>
520
+
521
+ Issue: See
522
+ <a href="http://lists.w3.org/Archives/Public/www-style/2008Nov/0022.html">F2F minutes</a> ,
523
+ <a href="http://lists.w3.org/Archives/Public/www-style/2008Oct/0268.html">dbaron's message</a> ,
524
+ <a href="http://lists.w3.org/Archives/Public/www-style/2010May/0247.html">Daniel's thread</a> ,
525
+ <a href="http://lists.w3.org/Archives/Public/www-style/2010May/0261.html">Gecko notes</a> ,
526
+ <a href="http://lists.w3.org/Archives/Public/www-style/2010May/0366.html">Opera notes</a> ,
527
+ <a href="http://lists.w3.org/Archives/Public/www-style/2010May/0280.html">Webkit notes</a>
528
+
529
+ Issue: Not sure if this is the correct way of describing the way things work.
530
+
531
+ <h3 id=highlight-cascade>
532
+ Cascading and Per-Element Highlight Styles</h3>
533
+
534
+ Each element draws its own portion of the <a>root highlight overlay</a> ,
535
+ which receives the styles specified by the <a>highlight pseudo-element</a> styles
536
+ for which it or one of its ancestors is the <i> originating element</i> .
537
+ When multiple styles conflict,
538
+ the winning style is the one belonging to the innermost element
539
+ after cascading.
540
+
541
+ <div class="example">
542
+ For example, if the following rules were applied:
543
+ <pre>
544
+ p::selection { background: red; color: yellow; }
545
+ em::selection { background: green; }
546
+ </pre>
547
+ to the following markup:
548
+ <pre>
549
+ <p>Highlight this <em> and this</em> .</p>
550
+ </pre>
551
+ The highlighted would be yellow throughout,
552
+ with a red background outside the <code> <em></code> element
553
+ and a green background inside it.
554
+ </div>
555
+
556
+ Issue: This could alternately be described in terms of inheritance.
557
+ The observable differences would be in how ''inherit'' and ''unset'' behave.
558
+ Should it inherit from the parent ''::selection''
559
+ or the <i> originating element</i> ?
560
+ Opera does the former, Gecko/Blink the latter.
561
+
562
+ <p class="advisement">
563
+ Authors wanting multiple selections styles should use
564
+ <strong> '':root::selection'' </strong>
565
+ for their document-wide selection style,
566
+ since this will allow clean overriding in descendants.
567
+ (''::selection'' alone would apply to every element in the tree,
568
+ overriding the more specific styles of any ancestors.)
569
+
570
+ <h3 id="highlight-painting">
571
+ Painting the Highlight</h3>
572
+
509
573
The ''::selection'' pseudo element draws its background
510
574
over the selected portion of the element,
511
575
immediately below any positioned descendants
@@ -533,10 +597,20 @@ Styling Highlighted Ranges</h3>
533
597
534
598
Issue: This whole section needs vocabulary cleanup.
535
599
600
+ <h3 id="highlight-security">
601
+ Security Considerations</h3>
602
+
603
+ Because the styling of spelling and grammar errors
604
+ can leak information about the contents of a user's dictionary
605
+ (which can include the user's name and even includes the contents of his/her address book!)
606
+ UAs that implement ''::spelling-error'' and ''::grammar-error''
607
+ must prevent pages from being able to read
608
+ the styling of such highlighted segments.
609
+
536
610
<h2 id="generated-content">
537
611
Generated Content Pseudo-elements: ''::before'' and ''::after''</h2>
538
612
539
- When their computed 'content' value is not ''none'' ,
613
+ When their computed 'content' value is not ''content/ none'' ,
540
614
these pseudo-elements generate boxes
541
615
as if they were immediate children of their <i> originating element</i> ,
542
616
and can be styled exactly like any normal document-sourced element in the document tree.
@@ -561,7 +635,7 @@ Generated Content Pseudo-elements: ''::before'' and ''::after''</h2>
561
635
562
636
<pre> p.note::before { content: "Note: " }</pre>
563
637
564
- Since the initial value of 'display' is ''inline'' ,
638
+ Since the initial value of 'display' is ''display/ inline'' ,
565
639
this will generate an inline box.
566
640
Like other inline children of <code> <p></code> ,
567
641
it will participate in <code> <p></code> ’s inline formatting context,
0 commit comments