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;
}
Sunday 11 November 2018
CSS selector - element with a given child
with a child
Subscribe to:
Post Comments (Atom)
php - file_get_contents shows unexpected output while reading a file
I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...
-
I have an app which needs a login and a registration with SQLite. I have the database and a user can login and register. But i would like th...
-
I got an error in my Java program. I think this happens because of the constructor is not intialized properly. My Base class Program public ...
-
I would like to use enhanced REP MOVSB (ERMSB) to get a high bandwidth for a custom memcpy . ERMSB was introduced with the Ivy Bridge micro...
No comments:
Post a Comment