CodeBrix.StyleSheetParse.MitLicenseForever
1.0.238.81
dotnet add package CodeBrix.StyleSheetParse.MitLicenseForever --version 1.0.238.81
NuGet\Install-Package CodeBrix.StyleSheetParse.MitLicenseForever -Version 1.0.238.81
<PackageReference Include="CodeBrix.StyleSheetParse.MitLicenseForever" Version="1.0.238.81" />
<PackageVersion Include="CodeBrix.StyleSheetParse.MitLicenseForever" Version="1.0.238.81" />
<PackageReference Include="CodeBrix.StyleSheetParse.MitLicenseForever" />
paket add CodeBrix.StyleSheetParse.MitLicenseForever --version 1.0.238.81
#r "nuget: CodeBrix.StyleSheetParse.MitLicenseForever, 1.0.238.81"
#:package CodeBrix.StyleSheetParse.MitLicenseForever@1.0.238.81
#addin nuget:?package=CodeBrix.StyleSheetParse.MitLicenseForever&version=1.0.238.81
#tool nuget:?package=CodeBrix.StyleSheetParse.MitLicenseForever&version=1.0.238.81
CodeBrix.StyleSheetParse
A fully managed, cross-platform CSS stylesheet parsing library for .NET.
CodeBrix.StyleSheetParse has no dependencies other than .NET, and is provided as a .NET 10 library and associated CodeBrix.StyleSheetParse.MitLicenseForever NuGet package.
CodeBrix.StyleSheetParse supports applications and assemblies that target Microsoft .NET version 10.0 and later. Microsoft .NET version 10.0 is a Long-Term Supported (LTS) version of .NET, and was released on Nov 11, 2025; and will be actively supported by Microsoft until Nov 14, 2028. Please update your C#/.NET code and projects to the latest LTS version of Microsoft .NET.
CodeBrix.StyleSheetParse is a fork of the code of the open source ExCSS library - see below for licensing details.
Installation
dotnet add package CodeBrix.StyleSheetParse.MitLicenseForever
Note that the NuGet package ID and the namespace are different - there is no package named plain CodeBrix.StyleSheetParse:
- NuGet package ID:
CodeBrix.StyleSheetParse.MitLicenseForever - Assembly and namespace:
CodeBrix.StyleSheetParse- i.e.using CodeBrix.StyleSheetParse;
Everything public lives in that one namespace. The package has no NuGet dependencies and no native libraries; it depends only on the .NET base class library. XML documentation (IntelliSense) ships alongside the assembly.
CodeBrix.StyleSheetParse supports:
- CSS stylesheet parsing from strings and streams
- Async parsing with cancellation support
- CSS selector parsing and specificity calculation
- Style rule, media query, and at-rule modeling
- @keyframes, @font-face, @supports, @container, @page, @import, @namespace, @charset, @document, @viewport rules
- Style declaration reading and manipulation
- CSS serialization (converting parsed stylesheets back to CSS text)
- Configurable parser tolerance (unknown rules, invalid selectors, comments, etc.)
- Many more...
CodeBrix.StyleSheetParse is a parser and object model, not a rendering or styling engine. It does not match selectors against a document, compute cascaded or inherited styles, validate CSS against a specification, resolve @import URLs or var() custom properties, or minify CSS. The one built-in formatter emits readable output; implement IStyleFormatter for anything else.
Sample Code
Parse a CSS Stylesheet
using CodeBrix.StyleSheetParse;
var parser = new StylesheetParser();
var stylesheet = parser.Parse("h1 { color: red; font-size: 24px; }");
foreach (var rule in stylesheet.StyleRules)
{
Console.WriteLine($"Selector: {rule.SelectorText}");
Console.WriteLine($"Color: {rule.Style.Color}");
}
Parse a CSS Selector and Check Specificity
using CodeBrix.StyleSheetParse;
var parser = new StylesheetParser();
var selector = parser.ParseSelector("div.highlight > span#title");
Console.WriteLine($"Selector: {selector.Text}");
Console.WriteLine($"Specificity: {selector.Specificity}");
Serialize a Stylesheet Back to CSS
using CodeBrix.StyleSheetParse;
var parser = new StylesheetParser();
var stylesheet = parser.Parse("h1 { color: red; } @media screen { p { font-size: 14px; } }");
string css = stylesheet.ToCss();
Console.WriteLine(css);
Documentation
The NuGet package includes AGENT-README.txt, a complete API reference and usage guide written for AI coding agents - point your agent at that file when it is writing code against this library.
Additional sample code and usage examples are available in the CodeBrix.StyleSheetParse.Tests project:
https://github.com/ellisnet/CodeBrix.StyleSheetParse/tree/main/tests/CodeBrix.StyleSheetParse.Tests
Note that the test project has InternalsVisibleTo access to the library, so some of what it calls (for example Stylesheet.Rules, MediaRule, SupportsRule, KeyframeRule and parser.ParseDeclaration) is internal and is not available to package consumers.
License
The project is licensed under the MIT License. see: https://en.wikipedia.org/wiki/MIT_License
All code originating from ExCSS was included as allowed by the MIT License permissible open source software license - as of ExCSS version 4.3.1. This project (CodeBrix.StyleSheetParse) complies with all provisions of the source code license of ExCSS v4.3.1 (MIT License).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CodeBrix.StyleSheetParse.MitLicenseForever:
| Package | Downloads |
|---|---|
|
CodeBrix.SvgParse.MsplLicenseForever
A renderer-agnostic SVG document object model (DOM) library for .NET. Provides comprehensive SVG parsing, element modeling, styling, and serialization capabilities. Supports loading SVG documents from files, streams, strings, and XmlReaders, and provides a rich object model for querying and manipulating SVG elements. |
|
|
CodeBrix.PdfDocCreate.Html2Pdf.MitLicenseForever
Renders author-created HTML pages with CSS styling into PDF documents via the CodeBrix.PdfDocCreate document object model. Applies a documented subset of CSS - inline style attributes, style blocks, and linked local stylesheets - with real selector matching, cascade, specificity, and inheritance. Embeds every image format CodeBrix.Imaging decodes plus SVG (referenced files, data: URIs, and inline svg elements, placed as PDF vector content by default, or rasterized on request - identically on Windows, macOS, and Linux, with no native dependency). All text is rendered with the CodeBrix.Platform.Fonts Roboto (sans-serif), Merriweather (serif), and Roboto Mono (monospace) font packages - plus the Noto companion families they bundle, which extend coverage to polytonic (ancient) Greek, Armenian, Georgian and music notation, and any fonts the consumer registers - so output is identical on every operating system. Designed for HTML/CSS written for PDF generation, not for repurposing arbitrary web pages. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.238.81 | 136 | 8/26/2026 |
| 1.0.165.124 | 814 | 6/14/2026 |
| 1.0.117 | 181 | 4/29/2026 |
| 1.0.102 | 138 | 4/14/2026 |