What's the proper way to write a CSS selector with a class AND a pseudo class? -


Simple question: What is the correct way to write a CSS selector with a class and a pseudo class?

For example:

  a.someclass: active {top: 1px; }  

or

  a: active.someclass {top: 1px; }  

Which is correct? If possible, can you give me a source on it - like W3C reference? I tried to find it, but I did not regret it.

Both of these are correct, although the first one is more common.

Here you can see that .class and : pseudo are both allowed at the same place, together with < Code> #id and [attrib = Val] selector:

  simple_selector: element_name [Hush | Class | Atrib | Pseudo] * | [Hush | Class | Atrib | Pseudo] +; class   : '.' Recognise; Pseudo: ':' [IDENT | Function S * [idnt s *]? ')'];  

Comments