DEV Community

loading...
Cover image for DISCUSS: If there's one CSS feature you could add, what would it be?

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

naseki profile image Naseki ใƒปUpdated on ใƒป1 min read

CSS has gone a very long way from being a simple stylesheet to something more dynamic. Think of calc() and CSS variables. They haven't turned CSS into a programming language, but they sure are helpful!

But there's still a lot that could be added to CSS! Now, imagine you were a wizard who possesses the entire W3 team and whoever works on our browsers... ๐Ÿง™โ€โ™‚๏ธโœจ

โœ Comment below answering the following question

If there was one CSS feature you could add that gets instantly supported by all major browsers, what would it be?

This can be a new feature or something that's already in W3 but isn't supported yet. It also doesn't have to be a property, you can think about functions as well. The possibilities are endless!


Naseki logo

Twitter | Website | Newsletter

Discussion (10)

pic
Editor guide
Collapse
jmdejager profile image
๐Ÿค๐Ÿฅ‡ Jasper de Jager

A parent selector

.myClass < span { display: block }

Collapse
naseki profile image
Naseki Author

Gosh, the many situations where I wished there was a parent selector! ๐Ÿ™ƒ

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
alohci profile image
Nicholas Stimpson • Edited
  1. attr() on all properties and on regular elements would be great.
  2. There was some great ideas in the 2003 Generated and Replaced Content draft, like ::outside pseudo element, ::before::before::before etc pseudo elements, deferring rendering with an ::alternate pseudo element. Wish we had those.
  3. If we can't have 2, then content:contents would be very helpful.
  4. CSS regions
  5. CSS exclusions.

Oops, that's five features. Just being greedy :-)

Collapse
naseki profile image
Naseki Author

Getting attr() on all properties would be absolutely great! If I had to pick one of these, it'd be most definitely that one! :)

Collapse
theyoungestcoder profile image
TheYoungestCoder

I would love to have a feature where you could sorta use javascript to select an element. This is what it would look like:

h1:javascript(element => someLogic(element))
Enter fullscreen mode Exit fullscreen mode

The javascript pseudo selector would require one argument: a callback function. That way you could use javascript logic to choose whether an element would be selected or not

Collapse
naseki profile image
Naseki Author

Hmm, that's a very interesting one! ๐Ÿ˜ฎโ˜ Not sure about using Js in CSS, but CSS could use some kinda programming logic, like what Sass has!

Collapse
vidabayer profile image
Comment marked as low quality/non-constructive by the community. View Code of Conduct
VidaBayer

Well I extremely agree with your words and it really makes me to understand the css. As I am a beginner and I was looking forward to more teachings so that I can bale to make my own cheap dissertation writing on this topic and let every one learn about it.