CSS4J implements the W3C's CSS Object Model API.

This CSS implementation can be used with either the DOM4J API or the regular W3C DOM API. Using it from DOM4J (through the classes in the dom4j package) is much easier, however. The classes in that package will give you access to the style sheet of an XHTML document as soon as you parse it.

On the other hand, if you choose the DOM way, you have to retrieve the embedded and linked CSS style sheets yourself, merge it with a default sheet, and then use the resulting style sheet to get the style declaration for the elements. In the future, helper classes may be available to simplify this task.

Rendering with CSS4J

CSS4J offers you more than an implementation of the W3C CSS OM API, as it brings you closer to the actual style formatting for a particular device, through the use of concepts like the style database. With the information provided by the style database, the CSS4J-specific interfaces automatically let you take into account the particular formatting for the target device, including the page size or the available fonts.

For example, if your style declaration for the font family of an element reads "Helvetica, Arial", and you happen to have only the second one available, on retrieving the font with the enhanced interface you will get the correct result, "Arial".

Read the descriptions of the individual packages for more information on the use of CSS4J.