[go: up one dir, main page]

Languages

Chapter 20
The CSS saga

This is chapter 20 of the book Cascading Style Sheets, designing for the Web, by Håkon Wium Lie and Bert Bos (2nd edition, 1999, Addison Wesley, ISBN 0-201-59625-3)

The saga of CSS starts in 1994. One of the authors of this book works at CERN - the cradle of the Web - and the Web is starting to be used as a platform for electronic publishing. One crucial part of a publishing platform is missing, however: there is no way to style documents. For example, there is no way to describe a newspaper-like layout in a Web page. Having worked on personalized newspaper presentations at the MIT Media Laboratory, Håkon saw the need for a style sheet language for the Web.

Style sheets in browsers were not an entirely new idea. The separation of document structure from the document's layout had been a goal of HTML from its inception in 1990. Tim Berners-Lee wrote his NeXT browser/editor in such a way that he could determine the style with a simple style sheet. However, he didn't publish the syntax for the style sheets, considering it a matter for each browser to decide how to best display pages to its users. Other browsers, including Pei Wei's Viola (1992) and the Harmony browser (1993) ( The Hyper-G system was one of the Web's early competitors) for the Hyper-G system had comparable style languages.

But instead of more advanced style sheets, the browsers that followed offered their users fewer and fewer options to influence the style. In 1993, NCSA Mosaic, the browser which made the Web popular, came out. Stylewise, however, it was a backwards step as it only allowed its users to change certain colors and fonts.

Meanwhile, writers of Web pages were complaining that they didn't have enough influence over how their pages looked. One of the first questions from an author new to the Web was how to change fonts and colors of elements. HTML at that time did not provide this functionality - and rightfully so. This excerpt from a message sent to the www-talk mailing list early in 1994, gives a sense of the tensions between authors and implementors:

(This message is available from the www-talk archive.)

In fact, it has been a constant source of delight for me over the past year to get to continually tell hordes (literally) of people who want to -- strap yourselves in, here it comes -- control what their documents look like in ways that would be trivial in TeX, Microsoft Word, and every other common text processing environment: "Sorry, you're screwed."

The author of the message was Marc Andreessen, one of the programmers behind NCSA Mosaic. He later became a co-founder of Netscape and by then his views - if they ever were his views - on formatting had changed. On October 13, 1994 Marc Andreessen announced to www-talk that the first beta release of Mozilla (which later turned into Netscape Navigator) was available for testing. Among the new tags the new browser supported was center and more tags were to follow shortly.

Three days before Netscape announced the availability of its new browser, Håkon published the first draft of Cascading HTML Style Sheets. Behind the scenes, Dave Raggett (the main architect of HTML 3.0) had encouraged the release of the draft to go out before the upcoming "Mosaic and the Web" (The "Mosaic and the Web" conference was held on October 17-20, 1995. It was the second conference in what has later become the WWW Conference Series) conference in Chicago. Dave had realized that HTML would and should never turn into a page description language and that a more purpose-built mechanism was needed to satisfy requirements from authors. Although the first version of the document was immature, it provided a useful basis for discussion.

Among the people who responded to the first draft of CSS was Bert Bos, the co-author of this book. At that time he was building Argo (The Argo browser was part of a project to make the Internet accessible to scholars in the Humanities. It featured plug-ins (which it called "applets") before Netscape added them), a highly customizable browser with style sheets and he decided to join forces with Håkon. Both of the two proposals look different from present-day CSS, but it is not hard to recognize the original concepts.

One of the features of the Argo style language was that it was general enough to apply to other markup languages in addition to HTML. This also became a design goal in CSS and "HTML" was soon removed from the title of the specification. Argo also had other advanced features that didn't make it into CSS level 1, in particular attribute selectors and generated text. Both features had to wait for CSS2.

"Cascading Style Sheets" wasn't the only proposed style language at the time. There was Pei Wei's language from the Viola browser, and Robert Raisch of the publishing house O'Reilly had written another, as early as June 1993. And then there was DSSSL, a complex style and transformation language under development at ISO for printing SGML documents. DSSSL could conceivably be applied to HTML as well. But CSS had one feature that distinguished it from all the others: it took into account that on the Web the style of a document couldn't be designed by either the author or the reader on their own, but that their wishes had to be combined, or "cascaded," in some way; and, in fact, not just the reader's and the author's wishes, but also the capabilities of the display device and the browser.

As planned, the initial CSS proposal was presented at the Web conference in Chicago in November 1994. The presentation at Developer's Day caused a lot of discussion. First, the concept of a balance between author and user preferences was novel. A fictitious screen shot showed a slider with the label "user" on one side and "author" on the other. By adjusting the slider, the user could change the mix of his own preferences and those of the author. Second, CSS was perceived by some as being too simple for the task it was designed for. They argued that in order to style documents, the power of a full programming language was needed. CSS went in the exact opposite direction by making a point out of being a simple, declarative format.

At the next WWW conference in April 1995, CSS was again presented (WWW3, the third conference in the WWW series, was held on April 10-14, 1995, in Darmstadt, Germany). Both Bert and Håkon were there (in fact, this was the first time we met in person) and this time we could also show implementations. Bert presented the support for style sheets in Argo and Håkon showed a version of the Arena browser which had been modified to support CSS. Arena had been written by Dave Raggett as a testbed for new ideas and one of them was style sheets. What started out as technical presentations ended up in political discussions about the author-reader balance. Representatives from the "author" side argued that the author ultimately had to be in charge of deciding how documents were presented. For example - it was argued - that there may be legal requirements on how warning labels has to be printed and the user should not be able to reduce the font size for such warnings. The other side, where the authors of this book belong, argued that the user, whose eyes and ears ultimately have to decode the presenta­tion, should be given the last word when there are conflicts.

Outside of the political battles, the technical work continued. The www-style mailing list was created in May 1995, and the discussions there have often influenced the development of the CSS specifications. Three years later there were already more than 4,000 messages in the archives of the mailing list.

In 1995 the World Wide Web Consortium (W3C) also became operational. Companies were joining the Consortium at a high rate and the organization became established. Workshops on various topics were found to be a successful way for W3C Members and Staff to meet and discuss future technical development. It was therefore decided that another workshop should be organized, this time with Style Sheets as the topic. The W3C technical staff working on style sheets (namely the two authors of this book) were now located in Sophia-Antipolis in Southern France where W3C had set up its European site. Southern France is not the worst place to lure workshop participants to, but since many of the potential participants were in the US it was decided to hold the workshop in Paris, which is better served by international flights. The workshop was also an experiment to see if it was possible for W3C to organize events outside the US. Indeed, this turned out to be possible and the workshop was a milestone in ensuring style sheets their rightful place on the Web. Among the participants was Thomas Reardon of Microsoft who pledged support for CSS in upcoming versions of Internet Explorer.

At the end of 1995, W3C set up the HTML Editorial Review Board (HTML ERB) to ratify future HTML specifications. Since style sheets were within the sphere of interest of the members of the new group, the CSS specification was taken up as a work item with the goal of making it into a Recommendation. Among the members of the HTML ERB was Lou Montulli of Netscape. After Microsoft had signalled that it was adding CSS support in its browser, it was important also to get Netscape on board. Otherwise, we could see the Web diverge in different directions with browsers supporting different specifications. The battles within the HTML ERB were long and hard, but CSS level 1 finally emerged as a W3C Recommendation in December 1996.

In February 1997 CSS got its own working group inside W3C and the new group set out to work on the features which CSS1 didn't address. The group was chaired by Chris Lilley, a Scotsman recruited to W3C from the University of Manchester. CSS level 2 became a Recommendation in May 1998, and level 3 will probably follow towards the end of 1999. In the meantime, not only HTML relies on CSS for its presentation. Many XML-based formats also need CSS, and the browsers that come out in late 1998 show the first, still somewhat limited, steps towards presenting XML data.

The W3C working group, whose official name is "Cascading Style Sheets and Formatting Properties Working Group," since they do more than just CSS, has about 15 members, delegated by the companies and organizations that are members of W3C. They come from all over the world, so the "meetings" are usually over the phone, about an hour every week. About four times per year, they meet somewhere in the world. Recent venues have been Provo, Redmond, San Francisco and Paris. In Paris the meeting was held at the offices of EDF-GDF, the French electricity and gas company. At that meeting, the group was offered a superb dinner: French cuisine overlooking Paris and the Seine - one of the few glamourous moments in the history of a hard-working technical working group. Every Frenchman must have been jealous; they don't normally get anything for free from their gas and electricity provider.

Browsers

The CSS saga is not complete without a section on browsers. Had it not been for the browsers, CSS would have remained a lofty proposal of only academic interest. The first commercial browser to support CSS was Microsoft's Internet Explorer 3 which was released in August 1996. At that point, the CSS1 specification had not yet become a W3C Recommendation and discussions within the HTML ERB were to result in changes that Microsoft developers, led by Chris Wilson, could not foresee. IE3 reliably supports most of the color, background, font and text properties, but does not implement much of the box model.

The next browser to announce support was Netscape's Navigator, version 4.0. Since its inception Netscape had been sceptical towards style sheets, and the company's first implementation turned out to be a half-hearted attempt to stop Microsoft from claiming to be more standards-compliant than themselves. The Netscape implementation supports a broad range of features - for example, floating elements - but the Netscape developers did not have time to fully test all the features which are supposedly supported. The result is that many CSS properties cannot be used in Navigator 4.

Netscape implemented CSS internally by translating CSS rules into snippets of Javascript, which were then run along with other scripts. The company also decided to let developers write JSSS, thereby bypassing CSS entirely. If JSSS had been successful, the Web would have had one more style sheet than necessary. This, fortunately for CSS, turned out not to be the case.

Meanwhile Microsoft continued its efforts to replace Netscape from the throne of reigning browsers. In Internet Explorer 4 the browser display engine - which among other things is responsible for rendering CSS - was replaced by a module code-named "Trident." Trident removed many of the limitations in IE3, but also came with its own set of limitations and bugs. IE4 does not fully support CSS1 - something that the Web Standards Project (WaSP) highlighted in November 1998 when they published "IE's Top 10 CSS Problems" (Figure 20.1).

Figure 20.1 The WaSP project tracks browser conformance to W3C Recommendations. One of their first reviews was the CSS support in Microsoft Internet Explorer.

Screendump of WaSP page about M

In addition to displaying static documents Trident is also capable of dynamically changing stylistic properties. For example, elements can be animated on the screen by continuously changing their top and left properties thus creating "Dynamic HTML" (DHTML). In principle, DHTML is very similar to JSSS (they both use scripting languages to set stylistic properties) but DHTML was never marketed as an alternative style sheet language. Indeed, CSS is an integral part of DHTML.

The third browser which ventured into CSS was Opera. The browser from the small Norwegian company made headlines in 1998 by being tiny (it fits on a floppy) and customizable while supporting most features found in the larger offerings from Microsoft and Netscape. Opera 3.5 was released in November 1998 and it supports most of CSS1. The Opera developers (namely Geir Ivarsøy) have also found the time to test their implementation before shipping it. The CSS1 test suite, developed by Eric Meyer with help from countless other volunteers, has made it significantly easier for implementors to test and improve their products.

As this text is being written, both Netscape and Microsoft are also working hard to get their next browsers out the door. Netscape has decided to replace the display engine in Navigator with "nglayout," which has been written from scratch with CSS as one of the foundations. Their new browser is code-named "Gecko" and you can download beta versions from http://www.mozilla.org. Microsoft has been releasing preview versions of Internet Explorer 5. Some CSS improvements are already in place, and it is expected that the WaSP initiative will remind the company that there is still some work to do before CSS1 is fully supported.

This book's Web site will have pointers to the latest CSS browsers.

Languages

About the translations