My CSS Wishlist

By  on  

Although CSS is a great formatting tool, the styling language has a long way to go to keep Web Developers satisfied. There are some definite holes in CSS that need to be filled. Until we get what I propose below, JavaScript can help fill some of the holes and so can images, but CSS should eventually incorporate my requests.

Variables

Variables are an absolute necessity in most other languages, yet CSS doesn't have variable capability. At this point, we're stuck with typing '#ffffea1' numerous times in our stylesheet. Being a PHP enthusiast, I think the '$' sign would be perfect for CSS variables.

@vars
{
	$white:#fff;
	$base:#000;
	$back:url(/graphics/background.jpg) top left no-repeat;
	$font:Helvetica;
}

/* and used like */

.my-div      { background:$back; color:$base; font-family:$font; border:1px solid $white; }

Importing Custom Fonts

Fonts are extremely lacking on the web. We're stuck with a core list of fonts and risk our website looking horrendous if we take the chance at using a font not supported/included in our visitors' computers. I propose the following syntax for importing custom fonts into our stylesheet.

@font
{
	family: 'MyFont'
	src:url(fonts/myfont.ext);
}

Resizable Elements

Resizables can now be accomplished using any of the popular JavaScript frameworks, but why not allow for resizable elements in CSS? We do use CSS units (ems, exs, etc.) that allow for scaling websites, but why not trigger resizing on demand? I think resizing should be as easy as:

.my-element
{
	resizable:x; /* or */
	resizable:y; /* or */
	resizable:xy;
}

Multiple Background Images

We all use "wrapper" DIVs and other elements to overlap background images -- why not just allow us to do it all in one CSS statement? Multiple background image specs are in the current CSS3 plans, but that still means we're years away from being able to rely on a browser having this capability.

Minimum and Maximum Font Sizes

We do our best to make our websites flexible and accessible, but there should be a point where we can tell the browser that the website simply can't/shouldn't be viewed with a font larger or smaller than x.

min-font-size:.7em;
max-font-size:6em;

I believe the above items would push CSS into a new stage of maturity and usefulness. What would you like to see in CSS?

Recent Features

  • By
    Serving Fonts from CDN

    For maximum performance, we all know we must put our assets on CDN (another domain).  Along with those assets are custom web fonts.  Unfortunately custom web fonts via CDN (or any cross-domain font request) don't work in Firefox or Internet Explorer (correctly so, by spec) though...

  • By
    Create a CSS Flipping Animation

    CSS animations are a lot of fun; the beauty of them is that through many simple properties, you can create anything from an elegant fade in to a WTF-Pixar-would-be-proud effect. One CSS effect somewhere in between is the CSS flip effect, whereby there's...

Incredible Demos

  • By
    Chris Coyier’s Favorite CodePen Demos IV

    Did you know you can triple-heart things on CodePen? We’ve had that little not-so-hidden feature forever. You can click that little heart button on any Pen (or Project, Collection, or Post) on CodePen to show the creator a little love, but you can click it again...

  • By
    Fx.Rotate:  Animated Element Rotation with MooTools

    I was recently perusing the MooTools Forge and I saw a neat little plugin that allows for static element rotation: Fx.Rotate. Fx.Rotate is an extension of MooTools' native Fx class and rotates the element via CSS within each A-grade browser it...

Discussion

  1. Great wishlist… these features should be implemented at CSS 3.0

  2. nice list. i was wondering, if you setup your webserver to process *.css files as php, can you use variables? i haven’t tried (yet) but I’m pretty confident it will work… I also give a confident vote for all those wishes :P

  3. I’ve seen that Alin. Why not just give CSS the ability to use variables instead of server-side processing?

  4. Very interesting ideas, although we now have @font-face for fonts, but I also miss variables.

    Another thing I have been thinking about is the possibility to define several properties to the same value, as in:

    img{
    height, width: 64px;
    }
    

    instead of:

    img{
    height: 64px;
    width: 64px;
    }
    

    In a large stylesheet, that would save some space.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!