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

I think "targeting anything that is a link, despite its history" is niche
enough to deserve some verbosity. The same way the spec doesn't provide a
`:remote-link` pseudo-class for external links, but instead tells you to
use `:not(:local-link)` instead.

On Tue, Feb 23, 2016 at 10:41 AM, Daniel Tan <lists@novalistic.com> wrote:

> 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 21:59:33 UTC