Re: [selectors] Any benefit of [att|="val"] over [att="val"], [att^="val-"]

On Wed, Sep 3, 2014 at 12:27 AM, James Craig <jcraig@apple.com> wrote:
> What's the benefit of this very specific and seemingly limited [att|=val] selector:
>
>         [lang|="en"] { /* properties */ }
>
> Over this combination of more extensible selectors?
>
>         [lang="en"], [lang^="en-"] { /* properties */ }
>
> If there is no real benefit, should it be dropped from the selectors module? If there is a benefit, please consider adding a note to the draft explaining the benefit.

The only benefit is one of brevity; if you have a longer selector,
you'd have to duplicate the entire thing.  As noted, though, |=
predates ^=.

Note as well that you shouldn't be using attribute selectors for the
lang attribute; use the :lang() pseudo-class instead, as it handles
some subtleties of language subtag matching better, and lets you match
multiple languages at once.

~TJ

Received on Wednesday, 3 September 2014 15:49:13 UTC