W3C home > Mailing lists > Public > www-style@w3.org > March 2012

[selectors4] Universal Selector '*' (asterisk) elsewhere

From: Christoph Päper <christoph.paeper@crissov.de>
Date: Thu, 29 Mar 2012 11:25:49 +0200
Message-Id: <04411633-9C4E-435D-92C9-A94A2C406352@crissov.de>
To: www-style CSS <www-style@w3.org>
The character ‘*’ can be used as a wildcard – meaning “any but not none” – for element names and namespaces. Level 4 also clarifies that it can be used with language (sub)tags in ‘lang()’. Should the asterisk be meaningful in other places, too?

  #*            – any ID
  .*            – any class
  ::*           – any pseudo-element
  :*            – any pseudo-class
  :*()          – any parametric pseudo-class
  :*(*)         – any parametric pseudo-class with any value
  :*(foo)       – any parametric pseudo-class with a certain value
  :foo(*)       – any value for a certain parametric pseudo-class
  [*]           – any attribute
  [*=*]         – any attribute with any value
  [*=foo]       – any attribute with a certain value
  [foo=*]       – any value for a certain attribute

Note that

  [foo*=bar]    – a certain attribute containing a certain string at least once in its value

already has defined semantics. The asterisk is already meaningful in parametric pseudo-classes that expect a selector as an argument. Also consider that some parametric pseudo-classes accept math-like arguments, i.e. “An+B”, where the asterisk may look like a multiplication sign and thereby be confusing:

  :foo(*n)      – any A
  :foo(*)       – any B
  :foo(+*)      – any B
  :foo(-*)      – any B
  :foo(*n+*)    – any A and any B

I haven’t tried to think of use-cases for any of this yet, but attribute names and probably values seem like a natural extension, because like element names they depend on the document language. I wonder whether these should be equivalent:

  :foo
  :foo(*)
or
  :foo
  :foo()
or
  :foo()
  :foo(*)

  :*(foo)
  :(foo)

  E[*]
  E[*=*]

  E[foo]
  E[foo=*]

I assume the following are equivalent already, although not explicitly mentioned:

  E
  E[]
Received on Thursday, 29 March 2012 09:26:38 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 22 May 2012 03:48:53 GMT