CSS Parser is a Java library that reads Cascading Style Sheets source text and outputs a Document Object Model Level 2 Style tree. Alternatively, applications can use SAC: The Simple API for CSS.
Its purpose is to allow developers working with Java to incorporate Cascading Style Sheet information, primarily in conjunction with XML application developments.
The CSS Parser package includes parsers for CSS Levels 1, 2, 2.1, and 3. It is freely available under the Apache License, Version 2.0.
CSS Parser depends on the SAC (Simple API for CSS) library (org.w3c.css.sac), whose last release — version 1.3 — dates back to 2008. The W3C itself describes SAC as a draft that may be “updated, replaced or obsoleted.” Because SAC is no longer evolving, CSS Parser cannot properly represent modern CSS constructs.
To overcome this limitation, the HtmlUnit-CSSParser project was created. It started as a fork of CSS Parser 0.9.25, removed the SAC dependency, and introduced a more flexible object model that can grow with the CSS specification. It is the CSS parser powering HtmlUnit since version 1.30.
We recommend new projects start with HtmlUnit-CSSParser, and existing users consider migrating when convenient. See the Migration Guide for a detailed comparison and step-by-step instructions.
CSS Parser remains available and functional. The current release is version 0.9.30 (December 2022).
Download the latest release from the SourceForge Project Page.
Continued maintenance of CSS Parser — including bug fixes, security patches, and compatibility updates — is available through sponsorship. If your project depends on CSS Parser and you need ongoing support, please contact the maintainer via the GitHub page to discuss sponsorship options.
Users are invited to ask questions and post feedback via the project's Tracker and Public Forums on SourceForge.
Obtain the Document Object Model Level 2 Style Recommendation for details of the DOM interfaces provided. For more information on using the SAC interface, go to the SAC Home Page.