If you could add any element or attribute or selector to CSS what would it be? I’ve asked myself this a lot (usually it’s been in reflective moment after trying to get some crazy layout to work, but that I know just isn’t going to happen).
I’ve often wondered that if certain things were fully supported in CSS (like border-radius) then we wouldn’t have to bend over backwards implementing crazy things like the sliding doors method for rounded looking buttons in all browsers. The idea of new CSS functionality is to be able to write more semantic code, without the need to wrap certain elements in useless DIVs or SPANs just to give a certain effect. In a list I’m going to list ideas of what I think would make CSS much more effective as a designer. In no way am I stating these as completely original and my own. Anything from selectors to new functionality are acceptable, and if you feel something should be on this list that is not, be sure to let me know in the comments.
Multiple Background Images
If this were implemented, it would be much easier to add complex textures to a single DIV that has a dynamic size. Say the top of a section needs a slight gradient, as does the bottom. As of now, you’d have to have two DIVs (one as a wrapper), both containing the background images needed for these gradients (on for top, the other for bottom).
http://www.w3.org/TR/2005/WD-css3-background-20050216/#layering
Native Gradients as Backgrounds
As it stands, we can use solid colors or images for backgrounds. It’s impossible to have a gradient background image stretch for the entire heights or width of a dynamically size element, so working around this using semantic code is out of sight. If there was a way to set points of beginning and end, along with color values (and possibly even alpha) this would be a great answer to an immense need.
http://webkit.org/blog/175/introducing-css-gradients/
Dynamic Background Image Size
I know that it’s not a good general practice to have CSS resize your images, but I think that if we were able to scale the background images based on the size of the element, using attributes like fitting to height or width as well as keeping aspect ratio, it would open up a whole lot of possibilities for layouts. Granted, I don’t think I would want it to scale up the images (for obvious reasons).
http://webdesign.about.com/od/styleproperties/p/blspbgsize.htm
Expressions/Variables/Computing
Although some might think this is a bad idea, there have been many a times where I wish I could use PHP in my CSS. Not only would it make templating so much easier (imagine creating a palette of color combinations, and then being able to modify your color scheme on the fly by changing only a couple values), but would allow for much richer possibilities in user generated styles.
What language would be used for this? Or would a knew language be created?
http://disruptive-innovations.com/zoo/cssvariables/
http://gadgetopia.com/post/2774
:parent(x) Selector
It would be extremely nice to be able to select the parent of a certain element. There is currently no way to do this. You are only allowed to move down the tree, and not up. I have sometimes implemented jQuery to select parent elements and assign a class attribute.
http://journal.adityamukherjee.com/essay/css-parent-selector-or-reverse-selector/
For the time being, this is all that I can think of. If you have any suggestions, feel free to let me know, and I’d love to add it.