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

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