Tag Archives: w3c

CSS Wish List

Don’t get me wrong, I think CSS is awesome. It is a great way of defining the UI, but it could be even better. I’m excited about the special effects, transitions, and graphic elements currently being added to the CSS specification. They will help us write faster pages by eliminating the need for UI graphics for things like rounded corners. On the other hand, we also need to add structure to the language to make it easier for designers and developers to author new pages and applications. I hope the CSS Working Group will consider my suggestions.

  • Make CSS a better declarative language
  • Abstract repeating patterns in the code
  • Do not make CSS a programming language

Suggestions for the CSS Working Group

The community has been talking about some form of constants or variables in different incarnations for almost a decade, it is time to make this a reality. While it is possible to duplicate this functionality with a preprocessor (an excellent stop gap until browser support catches up), ultimately this is a tool which should live within the CSS itself. It is a powerful way of expressing more about the objects we are building.

The mixins and prototypes (and associated includes and extends properties) are designed to allow document authors to abstract reusable bits of code and better manage and maintain their style sheets. The goal is to mimic the effect of using multiple class names in the HTML without the drawbacks associated with current implementations. Authors need extends and include in order to write faster, smaller, more efficient style sheets.

CSS is a powerful expressive language. It needs certain modifications so that it will be robust, maintainable, and easy to implement.

From JSConf.eu

How did this begin?

At some point, I realized I was coding CSS with a bunch of “rules” and best practices that weren’t the currently accepted norm. I found myself writing comments to try to express these rules like:

/* ----- faq (extends mod) ----- */


/* margin top = bottom height - corner height */

At that point I realized that I was trying to express via comments something which was missing from existing CSS syntax. I looked at other proposals and my own work building web sites for the last 9 years (eek! almost a decade). I first cataloged many of the rules because, at this point, they were mostly intuition and I needed to figure out why I do things the way I do.

When that had stabilized, I began to explore a syntax for this new language of declarative objects. Trying to balance standard programming practices with a desire that the syntax fit well with document authors expectations for how the language works.

CSS Inheritance Today

It is currently possible to implement CSS inheritance in three ways, however, each has its drawbacks.

  1. Multiple class names, clog the HTML with classes that have the same semantic value (just more or less abstract). They introduce an unnecessary dependency because CSS inheritance is defined in the HTML.
  2. By chaining comma delimited selector strings, authors lose the ability to group related rules into discrete blocks of code. The quantity of code increases dramatically. A preprocessor could make option #2 more feasible, but abstracting a necessary part of the language into another layer isn’t a permanent solution. As well, the resulting CSS is not human readable, this step should take place in the document tree.
  3. With a JavaScript parser, the heavy lifting could be done on the client-side, however this would likely have a negative performance impact particularly on older browsers and slower machines.

A Concrete Example – Based on YUI Standard Module Format

I found myself writing the following code:

/* weatherModule (extends .mod) */
.weatherModule .hd{...}
.weatherModule .ft{...}
.weatherModule .bd{...}

The html looked like this:

<div class="mod weatherMod">
  <div class="hd">Local Weather for SF</div>
  <div class="bd">Cloudy with 100% chance of rain, and fog.</div>
  <div class="ft"><a href="newLoc.html">Change your location?</a></div>

I was using multiple class names (which is great because ultimately it reduces the footprint of the CSS file by an order of magnitude), but it would be better if the browser could understand my intention, and process any instance of weatherModule as if it was also a mod.

<div class="weatherMod"> 
<!-- Can the browser treat this as an instance of mod? -->
  <div class="hd">Local Weather for SF</div>
  <div class="bd">Cloudy with 100% chance of rain, and fog.</div>
  <div class="ft"><a href="newLoc.html">Change your location?</a></div>

Thanks so much to the following people who gave invaluable advice, feedback, and (in some cases) tolerated an enormous number of iterations. Nothing gets created in a vacuum and dissenting opinions were as helpful as supporters. :) William Cook, David Federman, Gopal Vijayaraghavan, Douglas Crockford, Stoyan Stefanov, Ryan Grove, Marcel Laverdet, Eric Meyer, Dan Cederholm, Ethan Marcotte, Jeffrey Zeldman, Gonzalo Cordero, Jenny Han Donnelly, Chris Klaiber, Tantek Çelik, Jeremy Keith, Wendy Chisholm, Aaron Gustafson, Fred Sauer, Dave Hyatt, Eric Schurman, Brad Neuberg, John Allsopp, Tom Hughes-Croucher, Chris Mills, Nicholas C. Zakas, Peter-Paul Koch, Doug Schepers, Amy Hoy, Kyle Simpson, Brian LeRoux, Chris Blizzard, Philippe Le Hegaret and (of course) Daniel Glazman.

HTML5, who is bad enough to take on canvas?

HTML5 Superfriends

I recently went to New York to hang with some people who are interested in HTML5 and figure out what I thought about the future of this web standard. I’m a skeptic by nature, so I went into our little quest expecting to be unimpressed by HTML5, but in fact, it isn’t so bad, and even has a few additions I’m excited about.

Down with Pseudocode!

On the other hand the spec itself drives me crazy because I feel like pseudocode is a poor substitute for properly and clearly stating what you are trying to achieve. It is easy to mask your agenda in pseudocode and harder for people to sort out later what was intentional versus incidental.

#html5 .pseudo-code { display: none;} Thought experiments don’t belong in a spec & pseudocode can’t replace properly specifying requirements.


Additional Elements

One of the things that pleased me about the spec was what was not in it. While there are a bunch of additional elements that seem unnecessary, they haven’t gone too badly overboard. I suggested a sanity test of the data used to gather these classes because sometimes they got the name correct, but the use-case wrong. I won’t go into it here because it will be on the section titled “footer” in a document we will publish shortly.

Multinode Elements

I think we need a mechanism to define more complex structures than one element allows. I’d like to be able to define the small lego that make up the building blocks of my sites. The existing elements in the HTML 5 specification are more than sufficient, I’d just like to have a mechanism to define combinations of those that repeat throughout the site. It would also be great to be able to define error handling, for example, what happens if the browser finds a module with no body? Or automatically insert presentational junk so it doesn’t clutter dev code or add bytes over the wire.


It should be possible to do more with less javascript. I’d like to see browser support for common aspects of web pages as well as web applications. Practically every site in the known universe has toggle blocks, tabs, carousels, or accordion menus. I’d like to seen native browser support and CSS styling, so that these element incur no particular performance cost.

Woot! for mashups being compatible with standards

The addition of the section tag means we can mashup content from different sources without worrying about messing up a table of contents or site map generated from the pages of the site. Very cool. I thought section was completely stupid, but it has this cool feature, so now I’m satisfied.


Who isn’t excited about canvas? It pushes the boundaries of what we can do in our webapps and websites. Very very cool. On the other hand there is a giant gnarly unsolved technical problem with the canvas element. How do we provide universal access to an element that exists primarily via JavaScript? What would the API look like that insures that anyone can get the data goodies out of canvas and interact with its controls? What do browsers need to implement to make this workable? How can app developers get started today without ruining the accessibility of their work?

Standardistas meet JavaScripters, JavaScripters meet Standardistas. There. Much better. There are a few of us who span both worlds, but remarkably few considering how much our work overlaps. Maybe I should have said Ajaxian meet A List Apart, A List Apart, Ajaxian. You would probably like each other if you got to know one another. Though you don’t speak the same language, you both really care about users. ;)

Bespin raises questions about universal access to the canvas tag

Bespin raises questions about universal access to the canvas tag

We have a really cool technical problem to solve (In my book, really cool == hard, otherwise it would be boring!). If we are going to build bigger and more complicated stuff out of canvas (holy crap Bespin!), and we want to display data via interactive charts and controls, how in the world do we make this stuff universally accessible? How can we make sure search engines can see the data? How do people access it on any device? Without sight? Without a mouse (like cell phones).

We want the stuff we build to be used as widely as possible. So JavaScripters, what do you want from browsers? What could they do now that would make your life far easier? We need to solve this now, before this thing (HTML5) goes into Last Call and we end up with a half-baked solution. We’ve only just gotten started thinking about all the cool stuff we can build with Canvas, but the specification needs suggestions now. Where is the developer bad-ass enough to figure it out? Is there anything we can learn from flash? SVG?