Selecting an element with specific descendants using CSS3
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Selecting an element with specific descendants using CSS3
It's not quite programming but it is a puzzle. In the document below, I would like to have a CSS3 rule which puts A.0 and B.0 in bold type but leaves C.0 with a normal weight. The comments there show what I have tried but which does not work. Is there a way to do that in CSS3?
The proposed CSS4 may have the :has selector, but I'm looking for a way to do that in CSS3. Specifically I would like something which renders in both Firefox and Chromium.
PS. The above was blocked by LQ until javascript was activated. That is not a good move by LQ.
I wouldn't know about (or condone) Chrome, but :has() works in Chromium and not Firefox. It also works in the Chromium derivative Brave and thus presumably all the other Chromium derivatives.
However, as mentioned, a requirement is a solution that works in Firefox, too. I'd like to keep the logic for that in CSS3. I suppose it might be necessary to move it into the generator, but that would be more effort.
I took a new look at the script which produces that HTML and adding two lines to it was sufficient to produce a work-around. The one line is just a for-loop iterating through an XPpath:
I'm confused as to what you actually want to do here. Is it to have different handling for the last immediate child, as I'm getting from your description? If so, what are the classes for, and why are all your attempts trying to use them?
The sample makes a nested list two levels deep. The initial levels of the list A.0, B.0, and C.0 should reflect the presence of any descendant list item with the class of "aok". So elements containing A.0 and B.0 should end up rendered as bold text while C.0 should not be.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.