views:

74

answers:

2

How would you get the following tag using CSS?

<p>You can only use the text inside the tag</p>

As in xpath I'd use the following:

//p[contains(text(), "inside the tag")

PS: I can't close the xpath, it tries to auto complete with code... :S

+3  A: 

I believe CSS3 selectors can only filter attributes, not the text within tags. So you could do something like a[href~="aspx"] to match links to aspx pages, but that's as far as content-based matching can go.

For what you want to do, you'll probably have to use javascript or server-side processing.

Have a look at quirksmode and W3 for more information.

Johnny G
I'm almost sure that css selector exists. Thanks for the recommendations but I'd like to use the CSS selector as a Selenium locator, so only pure CSS can be used...
A: 

This is what I was looking for!!

p:contains("inside the tag")
What browsers support this?
mateusza