W3C home > Mailing lists > Public > www-style@w3.org > November 2011

Re: Composite pseudo classes

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 9 Nov 2011 08:42:17 -0800
Message-ID: <CAAWBYDD_bsWHioUGi9krqkaEW7-zdokjWs2tRUHT4jHnH+Vwww@mail.gmail.com>
To: Pete Boere <pete@the-echoplex.net>
Cc: www-style@w3.org
On Wed, Nov 9, 2011 at 4:15 AM, Pete Boere <pete@the-echoplex.net> wrote:
> Usually when using the :hover pseudo class it is appropriate to also use the
> :focus pseudo class for accesibility reasons. [1]
>
> Is it possible to have composite pseudo classes for this purpose?
> I've implemented a kind of composite pseduo class in a PHP CSS
> preprocessor[2] like this:
>
> .nav a:hocus { ... }
> .nav a:pocus { ... }
>
> compiling to
>
> .nav a:hover, .nav a:focus { ... }
> .nav a:hover, .nav a:focus, .nav a:active { ... }
>
> internally a substitiution is being made using an :any (:matches) shim [3]
> :hocus => :matches(:hover,:focus)
>
>
> [1]
> http://www.456bereastreet.com/archive/201004/whenever_you_use_hover_also_use_focus/
> [2] http://the-echoplex.net/csscrush
> [3]
> https://github.com/peteboere/css-crush/blob/master/plugins/hocus-pocus.php

Like Brian said, he and I and Boris Zbarsky have been privately
brainstorming over something like this.

I think it's quite reasonable to have a mechanism to define aliases
for compound selectors.  This allows for CSS that is easier to read
and maintain (though I personally don't think that 'hocus' and 'pocus'
are very good names ^_^).

Something like this, perhaps:

@selector-alias :my-pseudo :matches(:focus, :active);

~TJ
Received on Wednesday, 9 November 2011 16:43:12 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:46 GMT