What you should know about CSS 2.1

By Simon Willison

CSS 2 revision 1 has been out as a candidate recommendation for nearly two months now, but there’s been surprisingly little discussion of it around the web. It’s an interesting specification, and one that any standards conscious web developer should be aware of.

CSS 2.1 revises CSS 2 to better reflect the current state of the browser market, and to build upon lessons learnt in the four years since CSS 2 was released. It trims out a number of features that were never really adopted by the overall CSS community, such as aural stylesheets (now relegated to an Appendix) and adds a small number of widely requested or implemented features, such as the colour keyword ‘orange’.

The best guide to what’s new in CSS 2.1 can be found in the specification itself in the CSS 2.1 vs CSS 2 section. While most of the differences are subtle, the end result is a significant improvement over CSS 2 and forms a much better foundation for CSS going forward.

  • See also my editorial in the Tech Times #84 on this subject.

  • Well, there is at least one really large change that is worth to mention IMHO, and that is the behavior of the box model relating to floats. It’s been revised, so now it is possible to use the floats without assigning an explicit width and have them size to the content (auto, the default value for width, evaluated to 0 in CSS2.0). This fix is one that really have an impact on how you can use floats without having a fixed width container, instead relying on contents for sizing. (Also note that most browsers already behaved the CSS2.1 way, except for op7 and moz in some rather special occasions where other properties and conditions play a part.)

  • Now with added CSS Orange; I’ve been following CSS 2.1 progress since 2002 mainly for the errata aspects.

Get the latest in JavaScript, once a week, for free.