I'm looking to make a selector which will select all elements if they have a specific child element. For example, select all Possible? Answer Is it possible to select an element if it contains a specific child element? Unfortunately not yet. The CSS2 and CSS3 selector specifications do not allow for any sort of parent selection. This is a disclaimer about the accuracy of this post from this point onward. Parent selectors in CSS have been discussed for many years. As no consensus has been found, changes keep happening. I will attempt to keep this answer up-to-date, however be aware that there may be inaccuracies due to changes in the specifications. An older "Selectors Level 4 Working Draft" described a feature which was the ability to specify the "subject" of a selector. This feature has been dropped and will not be available for CSS implementations. The subject was going to be the element in the selector chain that would have styles applied to it. lorem ipsum dolor sit amet consecteture edipsing elit This selector would style the This selector would style the A more recent "Selectors Level 4 Editor’s Draft" includes "The Relational Pseudo-class: In any event, continuing the example from above, to select the * This makes me wonder if jQuery had implemented selector subjects whether subjects would have remained in the specification..
A Note About Specification Changes
Example HTMLspan
elementp span {
color: red;
}p
element!p span {
color: red;
}:has()
":has()
would allow an author to select an element based on its contents. My understanding is it was chosen to provide compatibility with jQuery's custom :has()
pseudo-selector*.p
element that contains a span
one could use:p:has(span) {
color: red;
}
Monday, May 27, 2019
CSS selector - element with a given child
with a child
Subscribe to:
Post Comments (Atom)
plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV
In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...
-
This question attempts to collect the few pearls among the dozens of bad C++ books that are published every year. Unlike many other programm...
-
I need to do the following: My current address looks like: https://www.domain.com I want to redirect with htaccess: www.domain.com TO https:...
-
using namespace std; So far in my computer science courses, this is all we have been told to do. Not only that, but it's all tha...
No comments:
Post a Comment