W3C home > Mailing lists > Public > www-style@w3.org > September 2014

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 3 Sep 2014 08:48:26 -0700
Message-ID: <CAAWBYDCCvvvwCq+vHjzt9a5nPrELFnQaQcH556T8ruJ2k4M4qQ@mail.gmail.com>
To: James Craig <jcraig@apple.com>
Cc: www-style list <www-style@w3.org>
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.

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

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:46 UTC