I want to know is there a way to doing something like this in CSS:
.menu a:match(:active:hover:visited)
{ }
instead of
.menu a, .menu a:active, .menu a:hover, .menu a:visited
{ }
If your a have same color for all states so, it's better write like this:
.menu a{
color:red;
}
instead of
.menu a, .menu a:active, .menu a:hover, .menu a:visited{color:red}
No. There is currently no mechanism to do what you want. You need to list all the selectors in full, as per what you are trying to avoid:
.menu a, .menu a:active, .menu a:hover, .menu a:visited
CSS is currently more like a markup language than a programming language. As Litek notes in the comments, however, :matches:() proposed for CSS4 does exactly what you described (and more).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With