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

Proposal: regular expressions (or wildcards) in selectors

From: Alan Plum <ashmodai@mushroom-cloud.com>
Date: Tue, 16 Mar 2004 12:35:01 -0500 (EST)
Message-ID: <40573972.5040402@mushroom-cloud.com>
To: www-style@w3.org

Especially with browsers which for some reason do not understand how to 
handle elements with multiple classes in HTML, some people wish there 
was a way to have some kind of wildcard in an ID or class selector.
Allowing regular expressions would possibly help a little.

*[class=regexp(/myclass-(a|b)[0-9]+/)] {
     /* ... */

This would match any element with a class of "myclass-a" or "myclass-b" 
followed by any amount of digits.
This might however result in parsing errors with older browsers and thus 
not be backwards compatible.

For now a wildcard character would be enough, eg:

.myclass-a~5 {
     /* ... */


*[class=myclass-a~5] {
     /* ... */

for any class that begins with "myclass-a" and ends with a 5.
As this wildcard would have to be a symbol which does not occur 
elsewhere, it couldn't break the stylesheet for older browsers.

If it hadn't been made publically available with the errata of the last 
version, the character _ (underscore) could serve this purpose.


Alan Plum
Received on Tuesday, 16 March 2004 12:37:28 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:12 UTC