Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Css selector equivalent to '//div[contains(@class, 'a b') and not (contains(@style, 'c'))]'

The xpath is //div[contains(@class, 'a b') and not (contains(@style, 'c'))]

What would the equivalent CSS selector be? Easy to get first bit div[class*='a b'], but how to negate and combine them?

like image 358
Yi Zeng Avatar asked May 08 '13 03:05

Yi Zeng


2 Answers

You negate using the :not() selector and another attribute selector for the style attribute. To combine them, just attach the :not() to the end of what you already have.

The equivalent CSS selector would be

div[class*='a b']:not([style*='c'])
like image 171
BoltClock Avatar answered Oct 21 '22 14:10

BoltClock


You want to select div elements with both classes a and b you can use div.a.b .

If you want it not to contain a style attribute with value c you can use:

div.a.b:not([style*=c])
like image 43
Benjamin Gruenbaum Avatar answered Oct 21 '22 14:10

Benjamin Gruenbaum