DEV Community

Discussion on: DISCUSS: If there's one CSS feature you could add, what would it be?

Collapse
 
jmdejager profile image
🐤🥇 Jasper de Jager

A parent selector

.myClass < span { display: block }

Collapse
 
afif profile image
Temani Afif

it does exist: drafts.csswg.org/selectors-4/#rela... but we still need to wait too long for a tiny support

Collapse
 
alohci profile image
Nicholas Stimpson • Edited

The problem with a has() selector, according to Tab Atkins, is that means that any DOM mutation will cause the cascade for the entire document to have to be rebuilt, which is much too slow. There's some suggestions that a has-child() selector might be possible, but it still increases the sub-tree that needs its cascade rebuilt from everything under the mutated element's parent, to everything under the mutated element's grandparent, which may still be regarded as too great. So don't hold your breath waiting for support.

Thread Thread
 
jmdejager profile image
🐤🥇 Jasper de Jager

But if I was a wizard.. 🧙‍♂️✨ 😊

Collapse
 
thalitadev profile image
Thalita G.

Gosh, the many situations where I wished there was a parent selector! 🙃