Henry Yun
Henry Yun

Reputation: 544

How do I select all pseudo-class child elements?

Is there a more concise way of writing this CSS?

.vertical > a:link,
.vertical > a:visited,
.vertical > a:hover,
.vertical > a:active
{color:blue;}

I am just looking to select all the a pseudoclasses inside a .vertical div and set all to blue.

Upvotes: 2

Views: 1680

Answers (2)

Matt Asbury
Matt Asbury

Reputation: 5662

This is as basic as you can make it for all a tags within a .vertical class element:

.vertical a {color:blue;}

or:

.vertical > a {color:blue;}

for a tags that are immediate children of the .vertical class.

Upvotes: 0

Kobi
Kobi

Reputation: 138017

This should work:

.vertical > a

It is common to have a stronger rule that overrides it though, so you may have to use the pseudo-classes to create an equally strong rule, or use !important or other selectors to see the effects.

Upvotes: 2

Related Questions