mike
mike

Reputation: 639

How to combine/pipe multiple selectors?

Is it possible to combine multiple css selectors in a single expression ? For example I would like to match the nodes that have the parent class visit and children class Home and attribute name align, value left.

.visit > .Home works as expected but when I add the attribute filter [align="left"] it fails to return any result. I've tried something as below but its not working. I'm new to CSS so any guidance would be helpful. I assume/expect there is a AND(&&) operator equivalent which would pipe the result from the child combinator into the attribute selector but I can't find any.

.visit > .Home [align="left"]

Upvotes: 0

Views: 229

Answers (1)

Michael Benjamin
Michael Benjamin

Reputation: 371113

Your selector...

.visit > .Home [align="left"]

... is saying, select all elements with an attribute/value pair align="left", that are descendants of elements with the class Home, that are children of elements with the class visit.

Remove the space between .Home and [align="left"].

Then the selector will read: select all elements with the class Home AND an attribute/value pair align="left", that are children of elements with the class visit.

Upvotes: 1

Related Questions