David A. Wheeler's Blog

Fri, 02 Jun 2006

Autonumbering supported in Firefox 1.5!

Here’s another reason to use Firefox as your web browser, besides the fact that Firefox has a better security record and that Firefox has better support for web standards in general. Firefox 1.5 has added autonumbering support, and sites like mine are starting to use it. If you’re using a non-compliant web browser, like the current version of Internet Explorer, you’re missing out. But let’s back up a bit to the basics: HTML.

HTML has been a spectacularly successful standard for sharing information - web pages around the world use it. I write a lot of my papers directly in HTML, because it’s easy, using HTML makes them easily accessible to everyone, and it’s a completely open standard.

But HTML has several weaknesses if you’re writing long or technical reports. One especially important one is automatic numbering of headers: the original HTML specification can’t do it. When you’re reading a long report, it can be hard to keep track of where you are, so having every heading numbered (such as “section 2.4.3”) is really helpful. This can be solved by having programs directly insert the heading numbers numbers into the HTML text, but that’s a messy and kludgy solution. It’d be much better if browsers automatically added numbered headings where appropriate, so that the HTML file itself is simple and clean.

The W3C (the standards group in charge of HTML and related standards) agreed that automatic numbering was important, and included support for automatic numbering in the Cascading Style Sheets (CSS) standard way back in 1998. CSS is an important support standard for HTML, so that should have been it… but it wasn’t. Both Netscape and Microsoft decided to not fully implement the standard, nor try to fix the standard so that they would implement it. Soon afterwards Microsoft gained dominant market share, and then let their browser stagnate (why bother improving it, since there was no competition?). It looked like we, the users, would never get basic capabilities in HTML like auto-numbering.

I’m happy to report that Firefox 1.5 has added support for auto-numbering headings and other constructs too. So I’ve modified my CSS file for papers and essays so it auto-number headings; I’ve released my CSS file under the MIT/X license, so anyone else can use it. If you develop web content you may want to look at examples like mine for a reason, because…

It turns out that the story is more complicated. In the process of implementing auto-numbering, the Firefox developers found a serious problem with the CSS specification. Oops! The Mozilla Firefox bug #3247 and David Flanagan’s blog discuss this further. The Firefox developers talked with the W3C, and the W3C ended up creating “CSS 2.1”, an updated/patched version of the CSS2 standard that is in the process of being formally released.

What this means is that the examples for autonumbering in the “official” original CSS2 standard won’t actually work! Instead, you need to follow a slightly different approach as defined in the patched CSS2.1 specification.

Technical stuff: The basic problem involves scoping issues. To solve it, the counter-reset property must be in the main heading names (like h1, h2, etc.), and not in the “before” sections (like h1:before, h2:before, etc.) - in spite of all the examples in the original CSS2 spec. You can put counter-increment in either place, though the spec puts them in the :before sections so I have too.

Now people have yet another reason to upgrade to Firefox. Firefox has had better standards support for some time; there are now many sites that won’t display properly (or as well) if your browser doesn’t support the standards well. But here is a clear and functionally important difference.

I’m a big believer in standards, but they can only help users if they are implemented, and they will only be implemented if users demand standards compliance. I think that the more people switch to standards-compliant browsers, and the more that sites use standards (to encourage people to switch), the more pressure it will bring on the other browser makers to catch up. And that would be great for all computer users.

More broadly, this is also a good example of why it’s important to have implementations try out standards before they are frozen; they help avoid mistakes like this. Today, essentially every successful open standard is implemented by free-libre/open source software (FLOSS) - this makes sure that the standard is implementable, helps all understand what the standard means, and also helps other developers understand at least one way to implement it. This doesn’t mean standards aren’t important; standards are vital! And this also shows that when a mistake is made by a standards body, life is not over; standards bodies can work with implementors to fix problems. In fact, this shows that the best standards are those created from an interplay between standards developers and implementors, where standards are then made official after actual implementation experience.

path: /oss | Current Weblog | permanent link to this entry