CSS3 validator & test suite

QUESTION-HOW project review


Bert Bos

Bert Bos <bert @w3.org>
Sophia-Antipolis, France

20 September 2002


The QUESTION-HOW project demonstrates and promotes the use of W3C technologies for the Web. Work package 1 of that project deals with quality assurance for several individual technologies. One of those technologies is CSS and this talk describes the status of the work on the two "deliverables" relating to CSS.

The first deliverable is a CSS "validator," a program that checks for syntax errors in style sheets and also helps with spotting possible semantic errors, by issuing warnings for common pitfalls. The validator can be used online, as a service provided by W3C, or downloaded and run as a stand-alone program.

The other deliverable is a test suite for CSS level 3, or rather a set of test suites, since CSS3 consists of several modules and each module has its own test suite. Like the modules of CSS3 itself, the test suites are developed and published one by one or in small batches over a relatively long period of time, covering most of 2002 and 2003.

The people involved

The person responsible for the work on the CSS3 validator and the CSS3 test suites is Bert Bos (W3C). He is one of the original inventors of CSS and was editor of the CSS1 and CSS2 specifications and now of some modules of CSS3. He is also the chairman of the W3C working group on CSS and the coordinator for style sheets within W3C (both CSS and XSL technologies).

The validator for CSS3 is not released yet, since CSS3 itself is not completely ready. Update on the code follows the modifications that the working group is still making to several modules of CSS3. More about the state of the code and of CSS3 below.

As CSS3 consists of several modules, so, too, does the test suite. Two modules have been published so far. They were developed in the context of the CSS working group and are published and maintained by W3C. More test modules are being developed. More about the test suites below.

What is CSS?

"Cascading Style Sheets"

H1 {font: bold 24pt Times; color: red}

This presentation itself, of course, relies on CSS. The content is contained in a very simple HTML file, completely without any dependencies on the mode of presentation. It could be rendered in speech, in braille, on different types of screens or printed. Three style sheets are attached to it by the author: one for projection (meant for slide show presentation: multiple pages, large fonts), one for print (smaller fonts, notes aren't hidden) and one for viewing on a computer screen (smaller font, notes visible, no page breaks).

The reader can use his own style sheets as well, either in place of or together with the ones from the author. Most modern browsers have menus or dialogs for the user to configure his personal styles and switch between different styles and modes.

The place of CSS on the Web (1)

Communication over the Web allows enhancing, storing, summarizing, merging, etc., of information on behalf of the recipientt

CSS belongs to the circle labeled display - different views

The Web is a communications medium. People publish, other people read and publish in their turn. It is meant to be a peer-to-peer system, where everybody is both publisher and reader.

It is also meant to make maximum use of the fact that the communication goes over computers. Computers can adapt, combine, enhance and compare multiple sources very quickly. But computers aren't very smart yet and so the authors must give them a hand. (That is what the semantic Web is about: finding the right compromise between the user being more explicit than he would be in person to person conversation, while not making it too hard on him and giving him other benefits in return.)

Style sheets play a role in adapting the presentation of content to different environments. The author can provide multiple views, but so can the reader

The place of CSS on the Web (2)

W3C goals & methods:

In particular:

CSS widely used since 1996

The information (and the services) offered on the Web should be accessible to as many people as possible, independent of handicaps, physical location, culture, equipment, etc. it should also be accessible to people in the future, and thus the technologies are designed to be extensible and modular.

Authors should take the different circumstances of their readers into account, but they cannot know everything. Therefore the reader should be able to adapt the display of the information. The author may not know how to make a rendering in speech, but as long as he uses HTML (in the correct way), the reader will be able to.

The usual method that W3C proposes is to split a resource into the parts that are at different levels of device-independence. E.g., a document can be split into the content proper and its abstract structure (HTML), images (PNG, SVG, various sizes) and style sheets (for different devices). The reader has a single, device-independent URL (in this case of an HTML file), and the resource at that URL in turn contains links to the other parts that are needed to display the resource.

The links must be accompanied by metadata (or the parts must themselves include metadata), so that the reader's software knows which parts to use.

The validator

Screenshot of validator

The validator that is online now is the validator for CSS2. The CSS3 validator is based on that, but contains many more properties and profiles. The CSS2 validator was developed in an earlier EU project, W3C-LA, and has been maintained by W3C since.

The validator is written in Java and can be downloaded and run as a stand-alone program. The source is available under the W3C license, which is Open-Source-compatible.

The validator can also be used on-line: W3C offers the validator as an on-line service. The service is very popular (many thousands of validations per day) and is still increasing in popularity. Some Web browsers and editors provide the validator in their menus

The test suites


The obvious goal of a test suite is to see how well a program implements a specification, but in practice it is not just those who develop programs who look at the test suite. It turns out that many people use it to understand the spec, because they find the spec often hard to read.

In fact, the writers of the specification also benefit from the test suite, because it uncovers ambiguities and holes in the specification.

CSS was the first W3C technology to have a test suite. Over time, the CSS working group has developed a standard format for its tests and that format is now fully documented. The documentation is published by W3C and can be found on the start page of the CSS test suites.

Project status

Konqueror has the CSS validator in its menus.


Test suites:

The validator has been written, but it has not been put on-line yet, since it contains code to validate modules of CSS3 that have not been finalized yet. Some of those modules are still being modified by the CSS working group and the code is being maintained to be up to date when it is finally published.

Meanwhile, people interested in running the code themselves or in helping with its development can find it in W3C's (read-only) CVS repository.

Two test suites are available, corresponding to the two modules that are furthest advance on the path to standardization: Selectors and Mobile Profile 1.0. W3C also published the documentation for test suite writers, that explains the format of the test suites.

Future plans


Test suites:

The validator will be installed in place of the current CSS2 online validator, as soon as a sufficient number of CSS3 modules is ready.

To help people with contributing tests to the test suites, we plan to open a space on the W3C CVS server, where people can see (read-only, unless they become an official collaborator) test suites that are being developed but not published yet.