If I read the specification correctly, no.
You can match on an element, the name of an attribute in the element, and the value of a named attribute in an element. I don't see anything for matching content within an element, though.
Answer from Dean J on Stack OverflowIf I read the specification correctly, no.
You can match on an element, the name of an attribute in the element, and the value of a named attribute in an element. I don't see anything for matching content within an element, though.
Looks like they were thinking about it for the CSS3 spec but it didn't make the cut.
:contains() CSS3 selector http://www.w3.org/TR/css3-selectors/#content-selectors
What is the difference between a selector and an element?
CSS selector difference: element element vs element>element - Stack Overflow
Extract a unique CSS selector for any element on any page (bookmarklet)
In Chrome you can just inspec the element, right click it in the DOM and select "Copy CSS path", example:
#siteTable_t1_cvq0sdw > div.thing.id-t1_cvq1631.noncollapsed.comment > div.entry.unvoted.RES-keyNav-activeElement > p > a.author.submitter.may-blank.id-t2_c81si.userTagged
will select OP's name in the reply to Thykka
More on reddit.comCSS selector in chrome developer tools?
Videos
When I look up the anatomy of CSS, it seems these two are interchangeable, although I'm sure that can't be true since they the two terms coexist. What are the key differences between these two that I should know?
tag full of text, a specific
- full of list items, or a specific
The difference is depth. What the w3schools site doesn't explain very well is that E>F only matches immediate children of E, while E F matches descendants of any depth.
Using your example CSS, consider the following HTML snippet:
<div>
<p id="paragraph1">I'm paragraph 1</p>
<ul>
<li><p id="paragraph2">I'm paragraph 2</p></li>
</ul>
</div>
The first ruleset, div p, will match both p blocks. The second one, div > p, will only match paragraph1.
div p{}
This one applies to all p inside div
div>p{}
This one says p needs to be a direct descendent of div