@@ -20,7 +20,7 @@ Abstract: <b>Selectors</b> are patterns that match against elements in a tree, a
2020Abstract : Selectors Level 4 describes the selectors that already exist in [[!SELECT]], and further introduces new selectors for CSS and other languages that may need them.
2121At Risk : the column combinator
2222At Risk : The '':drop()'' pseudo-class
23- Ignored Terms : DocumentFragment, math, h1
23+ Ignored Terms : DocumentFragment, math, h1, host element, shadow tree, box tree
2424Link Defaults : html5 (element) a
2525</pre>
2626<style>
@@ -645,6 +645,23 @@ Data Model</h3>
645645 but can be used in the matching of pseudo-classes and pseudo-elements.
646646 </ul>
647647
648+ The first four bullet points in the list above are referred to as <dfn export title="feature">features</dfn> .
649+ The <a>simple selectors</a> which are keyed off of them
650+ (<a>universal selector</a> , <a>type selectors</a> , <a>ID selectors</a> , <a>class selectors</a> , and <a>attribute selectors</a> )
651+ are called <dfn export title="feature selector">feature selectors</dfn> .
652+
653+ While elements may lack any of the individual <a>features</a> ,
654+ some elements are <dfn export>featureless</dfn> ,
655+ which means that not only do they lack any <a>features</a>
656+ (and thus will never match a <a>feature selector</a> ),
657+ but any selectors that reference <a>features</a> ,
658+ such as '':not(div)'' ,
659+ also never match them.
660+ Thus, only <a>pseudo-classes</a> or <a>pseudo-elements</a> can be used to select them.
661+ Individual <a>featureless</a> elements may define additional restrictions on what kinds of selectors can match them.
662+ (For example, the <a>host element</a> in a <a>shadow tree</a> is <a>featureless</a> ,
663+ and can't be matched by <em> any</em> <a>pseudo-class</a> except for '':host'' and '':host-context()'' .)
664+
648665 In HTML,
649666 the DOM is used as the <a>element tree</a> .
650667 Each DOM element is an element in the <a>element tree</a> ,
@@ -800,56 +817,68 @@ Pseudo-classes</h3>
800817
801818<h3 id="pseudo-elements">Pseudo-elements</h3>
802819
803- <dfn id='pseudo-element' title="pseudo-element" export>Pseudo-elements</dfn> create abstractions about the document tree
820+ Similar to how <a>pseudo-classes</a> represent additional information
821+ not directly present in the document tree
822+ (or that is inconvenient to use),
823+ a <dfn export>pseudo-element</dfn> is an <em> element</em>
824+ not directly present in the document tree,
825+ used to create abstractions about the document tree
804826 beyond those specified by the document language.
805- For instance, document languages do not offer mechanisms to access
806- the first letter or first line of an element's content.
807- <a>Pseudo-elements</a> allow authors to refer
808- to this otherwise inaccessible information.
809- <a>Pseudo-elements</a> may also provide authors a way
810- to refer to content that does not exist in the source document
811- (e.g., the ''::before'' and ''::after'' <a>pseudo-elements</a>
812- give access to generated content in CSS [[CSS21]] ).
827+
828+ <div class="example">
829+ For instance, document languages do not offer mechanisms to access
830+ the first letter or first line of an element's content,
831+ but there exist <a>pseudo-elements</a>
832+ (''::first-letter'' and ''::first-line'' )
833+ that allow those things to be styled.
834+
835+ <a>Pseudo-elements</a> can also represent content that doesn't exist in the source document at all,
836+ such as the ''::before'' and ''::after'' pseudo-elements
837+ which allow additional content to be inserted before or after the contents of any element.
838+ </div>
813839
814840 The syntax of a <a>pseudo-element</a>
815841 is "::" (two U+003A COLON characters)
816842 followed by the name of the <a>pseudo-element</a> as an <a>identifier</a> .
817843 <a>Pseudo-element</a> names are <a href="#case-sensitive">ASCII case-insensitive</a> .
818844 No <a>white space</a> is allowed between the two colons, or between the colons and the name.
819845
820- This <code> ::</code> notation was chosen in order to establish
821- a discrimination between <a>pseudo-classes</a> (which subclass existing elements)
822- and <a>pseudo-elements</a> (which are elements not represented in the document tree).
823- However, for compatibility with existing style sheets,
824- user agents must also accept the previous one-colon notation
825- for <a>pseudo-elements</a> introduced in CSS levels 1 and 2
826- (namely, '':first-line'' , '':first-letter'' ,
827- '':before'' and '':after'' ).
828- This compatibility notation is not allowed any other <a>pseudo-elements</a> .
846+ Due to legacy constraints,
847+ user agents must allow ''::before'' , ''::after'' , ''::first-line'' , and ''::first-letter'' pseudo-elements
848+ to be written with a single colon rather than two,
849+ similar to <a>pseudo-class</a> syntax.
850+ Authors must always use the double-colon syntax for these <a>pseudo-elements</a> .
851+
852+ <a>Pseudo-elements</a> do not exist independently;
853+ they belong to another element on the page,
854+ called their <dfn export>originating element</dfn> .
855+ When a <a>pseudo-element</a> is encountered in a selector as part of a <a>compound selector</a> ,
856+ the part of the selector to the left of the <a>pseudo-element</a> selects the <a>originating element</a> for the <a>pseudo-element</a> ;
857+ the part of the selector to the right, if any, applies to the <a>pseudo-element</a> itself.
858+ If a <a>pseudo-element</a> <em> starts</em> a <a>compound selector</a> ,
859+ it's treated as if the selector to its left was the <a>universal selector</a> .
829860
830- Note: A future version of this specification may allow
831- multiple pseudo-elements per selector.
861+ <div class='example'>
862+ For example, in the selector ''div a::before'' ,
863+ the ''a'' elements matched by the selector are the <a>originating elements</a>
864+ for the ''::before'' pseudo-elements attached to them.
832865
833- Syntactically, a <a>pseudo-element</a> immediately follows
834- the <a>compound selector</a> representing its <dfn export>originating element</dfn> ,
835- i.e. the element to which it is associated.
836- Unless otherwise overridden by the definition of the <a>pseudo-element</a> :
866+ The selector ''::first-line'' is equivalent to ''*::first-line'' ,
867+ which selects the ''::first-line'' pseudo-element on <em> every</em> element in the document.
868+ </div>
837869
838- <ul>
839- <li> only one <a>pseudo-element</a> may appear per <a>complex selector</a>
840- <li> the <a>pseudo-element</a> must appear after the <a>compound selector</a>
841- that represents the <a href="#subject">subjects</a> of the selector
842- <li> the <a>pseudo-element</a> may appear only if the subject of the selector
843- is the last <a>compound selector</a> in the selector.
844- </ul>
870+ <a>Pseudo-elements</a> are <a>featureless</a> ,
871+ and so can't be matched by any <a>feature selector</a> .
872+ They also do not affect the interpretation of <a>structural pseudo-classes</a> ,
873+ which are evaluated based solely on real elements.
874+ Other <a>pseudo-classes</a> <em> can</em> match <a>pseudo-elements</a> ,
875+ unless otherwise specified.
845876
846- A <a>pseudo-element</a> may be immediately followed
847- by any combination of the <a href="#useraction-pseudos">user action pseudo-classes</a> ,
848- in which case the <a>pseudo-element</a> is represented only when it is in the corresponding state.
849- Whether these pseudo-classes can match on the <a>pseudo-element</a>
850- depends on the <a>pseudo-class</a> and <a>pseudo-element</a> ”s definitions:
851- unless otherwise-specified, none of these <a>pseudo-classes</a>
852- will match on the <a>pseudo-element</a> .
877+ <p class='issue'>
878+ I've switched over to defaulting to allowing.
879+ Is that okay,
880+ or should we stick with defaulting to *not* allowing,
881+ and requiring individual pseudo-classes to specify that they work on pseudo-elements?
853882
854883 <div class="example">
855884 For example, the '':hover'' pseudo-class specifies that it
@@ -860,8 +889,79 @@ Pseudo-classes</h3>
860889 the selector ''::first-line:focus'' will never match anything.
861890 </div>
862891
892+ <a>Pseudo-elements</a> may have children,
893+ as defined by the specification defining them.
894+ Their children can be children of other elements, too,
895+ turning the <a>element tree</a> into a directed acyclic graph,
896+ but their rendering must be defined so as to maintain the tree-ness of the <a>box tree</a> .
897+
898+ <div class='example'>
899+ For example,
900+ the ''::content'' pseudo-element treats elements distributed to it as its children.
901+ This means that, given the following fragment:
902+
903+ <pre>
904+ <div>
905+ <span>foo</span>
906+ <"shadow root">
907+ <content></content>
908+ </"shadow root">
909+ </div>
910+ </pre>
911+
912+ the selectors ''div > span'' and ''div::shadow ::content > span'' select the same element via different paths.
913+
914+ However, when rendered,
915+ the <code> <span></code> element generates boxes as if it were the child of the <code> <content></code> element,
916+ rather than the <code> <div></code> element,
917+ so the tree structure of the <a>box tree</a> is maintained.
918+ </div>
919+
863920 The host language defines which pseudo-elements exist and their meaning.
864- For CSS, [[CSS21]] defines the ::before, ::after, ::first-line and ::first-letter pseudo-elements.
921+ [[CSS21]] defines the ''::before'' , ''::after'' , ''::first-line'' and ''::first-letter'' pseudo-elements
922+ which exist in all document languages.
923+
924+ <h4 id='pseudo-element-types'>
925+ Types of Pseudo-Elements</h4>
926+
927+ <a>Pseudo-elements</a> are divided into two categories:
928+ <a>content pseudo-elements</a> ,
929+ <a>text pseudo-elements</a> ,
930+
931+ A <dfn export>content pseudo-element</dfn>
932+ “acts like an element”.
933+ It might be able to generate boxes
934+ (though it probably doesn't by default),
935+ and all properties are valid on it.
936+ While it is ignored by <a>structural pseudo-classes</a> ,
937+ it's otherwise treated exactly like an element inserted in its place.
938+
939+ <div class='example'>
940+ For example, the ''::before'' <a>pseudo-element</a> is a <a>content pseudo-element</a> ,
941+ as it can be styled like any other element
942+ (as long as its 'content' property is set to a non-''content/none'' value).
943+
944+ The ''::shadow'' <a>pseudo-element</a> is also a <a>content pseudo-element</a> ,
945+ even though it never generates boxes.
946+ It does, however,
947+ act as the parent of the top-level elements in its <a>shadow tree</a> .
948+ </div>
949+
950+ A <dfn export>text pseudo-element</dfn> ,
951+ on the other hand,
952+ never generates boxes.
953+ Instead, it generates fragments
954+ within the boxes generated by its <a>originating element</a> .
955+ Further, the fragments generated by a <a>text pseudo-element</a>
956+ can cross content boundaries of elements within the <a>originating element</a> .
957+ For these reasons,
958+ the properties that apply to <a>text pseudo-elements</a> are extremely restricted.
959+ <span class='issue'> Explain this better.</span>
960+
961+ <div class='example'>
962+ The ''::first-line'' and ''::first-letter'' <a>pseudo-elements</a>
963+ are both <a>text pseudo-elements</a> .
964+ </div>
865965
866966<h3 id="case-sensitive">
867967Characters and case sensitivity</h3>
0 commit comments