W3C home > Mailing lists > Public > www-style@w3.org > October 2009

Re: [Selectors] Clarify when universal selector may be omitted

From: Leif Halvard Silli <xn--mlform-iua@xn--mlform-iua.no>
Date: Thu, 22 Oct 2009 02:23:00 +0200
Message-ID: <4ADFA5E4.6040709@xn--mlform-iua.no>
To: fantasai <fantasai.lists@inkedblade.net>
CC: www-style list <www-style@w3.org>
fantasai On 09-10-21 02.41:

> Leif Halvard Silli wrote:


>> Is this meant to have the following meaning: ?
>>
>> ?!? If "*" *is neither* the only component (i.e. w/o prefix)
>>    *nor* immediately preceding a pseudo-element,
>>    THEN  the "*" may be dropped.
>>
>> If the answer is "yes, this is what is meant",

> 

> Yes, that is what is meant, and it is completely *unambiguous*
> due to the grammatical structure created by the use of "is" in
> both places, which is why I'm not dropping the "is".


I think in reality you disagree with what I intended above.

	FIRSTLY:

Change of position: I assume that both these are valid, right?

    *::marker {}/*Var1*/
     ::marker {}/*Var2*/

	SECONDLY:

Why do you specifically call out pseudo-elements? The current 
draft doesn't do that. [1] Or to ask differently, why isn't the 
following,

    *::marker{}

a case of a simple selector sequence where the "*" - quoting the 
text - "is not the only component of a sequence of simple selectors"?

1) Isn't pseudo-element covered by the word 'component'?
2) If yes, then what is 'pseudo-element' a component of, if not of 
a 'simple selector sequence'?
3) If it is a component of a 'simple selector sequences', then it 
is unecessary and confusing to call it out (this is what has 
confused me)

	THIRDLY:

This is what the spec says about what kind of 'component' a 
pseudo-element is:

The "simple selectors" definition paragraph says: [2]

   ]]A simple selector is either a type selector, universal
selector, attribute selector, class selector, ID selector, or
pseudo-class. One pseudo-element may be appended to the last
sequence of simple selectors in a selector.[[

Even if this paragraph defines the list of simple selectors, 
pseudo-element is not described as a simple selector. But it IS 
described as an appendix to a simple selector sequence. Thus it 
ought to be considered a component of a simple selector sequence, 
even if it (may) not (be) a simple selector itself.

3 paragraphs further down it is said, however:

   ]]An empty selector, containing no sequence of simple selectors 
and no pseudo-element, is an invalid selector.[[

Here the pseudo-element is not considered part of the simple 
selector sequence.

The pseudo element definition says: [3]

   ]]Only one pseudo-element may appear per selector, and if 
present it must appear after the sequence of simple selectors that 
represents the subjects of the selector.[[

Here too, pseudo-elements are not considered part of the simple 
selectors sequence.

However, the text about the negation pseudo class talks about both 
the negation pseudo-class and the pseudo-elements as simple 
selectors (why else would it, inside the same parenthesis, 
specifically exclude them both from "simple selectors"?): [4]

   ]]The negation pseudo-class, :not(X), is a functional notation 
taking a simple selector (excluding the negation pseudo-class 
itself and pseudo-elements) as an argument. It represents an 
element that is not represented by the argument.[[

The grammar section also considers pseudo-elements are part of a 
simple selector sequence - it says about pseudo-elements that they 
"occur only in the last simple_selector_sequence" - thus it is 
clearly a 'component' of a simple selector sequence: [5]

]]
pseudo
   /* '::' starts a pseudo-element, ':' a pseudo-class */
   /* Exceptions: :first-line, :first-letter, :before and :after. */
   /* Note that pseudo-elements are restricted to one per selector 
and */
   /* occur only in the last simple_selector_sequence. */
   : ':' ':'? [ IDENT | functional_pseudo ]
   ;
[[

And more directly, in the same grammar: [5]

]]
simple_selector_sequence
   : [ type_selector | universal ]
     [ HASH | class | attrib | pseudo | negation ]*
   | [ HASH | class | attrib | pseudo | negation ]+
   ;
[[

The CSS 2.1 grammar uses 'simple selector' instead of 'sequences, 
but otherwise has the same grammar w.r.t. 'pseudo':

simple_selector
   : element_name [ HASH | class | attrib | pseudo ]*
   | [ HASH | class | attrib | pseudo ]+
   ;

According to section 1.3 of CSS3 selectors, "the components of" a 
simple selector sequence are called "simple selectors": [6]

   ]]what was referred to in CSS2 as a simple selector is now 
called a sequence of simple selectors, and the term "simple 
selector" is now used for the components of this sequence[[

Thus, a pseudo-element, being a component of a sequence of simple 
selectors, should itself be a simple selector.

But then, the same section also discern between simple selectors 
and pseudo-elements ...: [6]

   ]]* new simple selectors including substring matching attribute 
selectors, and new pseudo-classes
     * new pseudo-elements, and introduction of the "::" 
convention for pseudo-elements [[

Finally, the Table of Contents lists simple selectors under 
section 6, while pseudo elements are listed in its own section. 
[7]. CSS 2.1 also discerns similarly (except in the grammar).

	CONCLUSIONS

* Simple selector sequences are made up of two kind of components:
  - simple selectors
  - pseudo elements
* 'Components of simple selectors' are not properly defined

[1] http://www.w3.org/TR/css3-selectors/#universal-selector
[2] http://www.w3.org/TR/css3-selectors/#simple-selectors-dfn
[3] http://www.w3.org/TR/css3-selectors/#pseudo-elements
[4] http://www.w3.org/TR/css3-selectors/#negation
[5] http://www.w3.org/TR/css3-selectors/#grammar
[6] http://www.w3.org/TR/css3-selectors/#changesFromCSS2
[7] http://www.w3.org/TR/css3-selectors/#contents
-- 
leif halvard silli
Received on Thursday, 22 October 2009 00:23:36 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:21 GMT