Question: I need a CSS selector that selects a `<select>` element if it contains an `<option>` which contains or equals (both would match my requirements) a specified text. Example HTML:

```
<select name="foo">
  <option value="1">First</option>
  <option value="2">Second</option>
</select>

```

I want the `<select>` if it contains for example an option labeled "Second". Something like this:

```
select[option:contains('Second')]

```

If there is no way to achieve that with CSS selectors, i'd also accept JQuery or XPath selectors.

Answer: 
You can't do this with CSS.

You can either use this jQuery selector ([`:has()`](http://api.jquery.com/has-selector) and [`:contains()`](http://api.jquery.com/contains-selector) are not part of CSS):

```js
$("select:has(option:contains('Second'))")

```

Or this XPath expression:

```
//select[contains(option, 'Second')]

```
```
$('select[name="foo"] option:contains("Second")').parent().addClass('selected');

```

Maybe this can help