W3C home > Mailing lists > Public > www-style@w3.org > April 2016

Re: [css-selectors] Tagname based substrings

From: Simon Pieters <simonp@opera.com>
Date: Thu, 07 Apr 2016 13:06:32 +0200
To: "Davis, Greg" <greg.davis@pearson.com>, "www-style@w3.org" <www-style@w3.org>, "Marat Tanalin" <mtanalin@yandex.ru>
Message-ID: <op.yfjqg6poidj3kv@simons-macbook-pro.local>
On Wed, 06 Apr 2016 20:18:03 +0200, Marat Tanalin <mtanalin@yandex.ru>  
wrote:

> 05.04.2016, 20:04, "Davis, Greg" <greg.davis@pearson.com>:
>> In my ongoing investigation of web components, I'm finding a place  
>> where I want to target a substring of a tagname to keep the authoring  
>> semantic. That is, when I author my tags like this:
>> <x-navigation />
>> <x-quiz />
>> etc...
>>
>> I want to namespace to them so they have shared attributes like fonts,  
>> etc. I can't find a way in the documentation on attribute substrings,  
>> but might just be missing it. Is there a way to target a tagname? I'm  
>> thinking like this:
>>
>> *[tagname^="x-"] { ... }
>
> This makes sense. The syntax you've provided is already used for  
> attribute selectors, so some functional notation could probably be used  
> instead, e.g.:
>
>     :tag-name(^"x-") {...}

It seems to me this could be equally useful for attributes, in particular  
data-* attributes.

While we're bikeshedding, a more succinct syntax would be IDENT DELIM(*)  
(no allowed whitespace between) so you can do:

     x-admin-* { ... }
     [data-my-*] { ... }

Performance-wise it seems to me this shouldn't be worse than partial  
attribute value selectors, but I could be missing something?

-- 
Simon Pieters
Opera Software
Received on Thursday, 7 April 2016 11:07:06 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:09:02 UTC