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

Re: [selectors4] Do we really need `:any-link`?

From: Daniel Tan <lists@novalistic.com>
Date: Tue, 23 Feb 2016 23:41:34 +0800
To: Yannick Ihmels <yannick@ihmels.com>
Cc: www-style@w3.org
Message-ID: <56CC7DAE.9010505@novalistic.com>
On 2/7/2016 12:15 AM, Yannick Ihmels wrote:
> Why do we need an additional pseudo-class `:any-link`, if we could
> simply write `[href]`? There are no issues with specificity, because
> they are equally specific [(0, 1, 0) vs. (0, 1, 0)].

Because [href] is specific to HTML. (To be pedantic, only a, area, link
elements with a href attribute will match the hyperlink pseudo-classes
in HTML.)

> You could also write `:matches(:link, :visited)`. Thatís clearer than
> a pseudo-class named ďany-linkĒ.

It is, but it's also more verbose. Granted, :matches is still useful
when using :link and :visited with more elaborate selectors, such as

     body > header > a:matches(:link, :visited)

being (slightly) shorter than

     body > header > a:link, body > header > a:visited

But for the simplest of cases, like

     a:link, a:visited

it's pointless to rewrite the above to use :matches as that would only
result in more bytes used:

     a:matches(:link, :visited)

-- 
Daniel Tan
NOVALISTIC
<http://NOVALISTIC.com>
Received on Tuesday, 23 February 2016 15:42:08 UTC

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