Posts

Showing posts with the label css-selectors

How to retieve specific text from a tag without using contains() and xpath?

How to retieve specific text from a tag without using contains() and xpath? <div> <label1>Hulk</label1> <label2>Ironman</label2> Thor </div> How do I get only Thor text without using contains in xpath ? If I try getting text of div it would give me all the 3(Hulk,Ironman,Thor) but I want only Thor. Show how did you try, current and desired output, add tag for your programming language – Andersson Jul 2 at 10:21 Assuming that the typo <label1? is fixed, and that there are no other div s in the document, //div/text() will select Thor . – jsheeran Jul 2 at 10:29 <label1? div //div/text() Thor @jsheeran ,...

Do CSS combinators add specificity to a CSS selector?

Image
Do CSS combinators add specificity to a CSS selector? The mdn article about CSS specificity states: Universal selector (*), combinators (+, >, ~, ' ') and negation pseudo-class (:not()) have no effect on specificity. (The selectors declared inside :not() do, however.) However my experience is that combinators do have an effect, see this example: div > p { color: red; } p { color: green; } <div> <p>First Paragraph</p> <p>Second Paragraph</p> </div> So the above quote claims, that CSS combinators have no effect on specificity. If that quote is right, how is it meant then, as my code example shows the opposite? possible duplicate of : stackoverflow.com/questions/2809024/points-in-css-specificity – Temani Afif Jul 1 at 19:11 could be except they never mention ...