CodeBrix.StyleSheetParse.MitLicenseForever
1.0.248.1122
dotnet add package CodeBrix.StyleSheetParse.MitLicenseForever --version 1.0.248.1122
NuGet\Install-Package CodeBrix.StyleSheetParse.MitLicenseForever -Version 1.0.248.1122
<PackageReference Include="CodeBrix.StyleSheetParse.MitLicenseForever" Version="1.0.248.1122" />
<PackageVersion Include="CodeBrix.StyleSheetParse.MitLicenseForever" Version="1.0.248.1122" />
<PackageReference Include="CodeBrix.StyleSheetParse.MitLicenseForever" />
paket add CodeBrix.StyleSheetParse.MitLicenseForever --version 1.0.248.1122
#r "nuget: CodeBrix.StyleSheetParse.MitLicenseForever, 1.0.248.1122"
#:package CodeBrix.StyleSheetParse.MitLicenseForever@1.0.248.1122
#addin nuget:?package=CodeBrix.StyleSheetParse.MitLicenseForever&version=1.0.248.1122
#tool nuget:?package=CodeBrix.StyleSheetParse.MitLicenseForever&version=1.0.248.1122
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.
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
CodeBrix.StyleSheetParse is licensed under the MIT License - see the LICENSE file.
For licensing and provenance information about the open source code included in this package, see THIRD-PARTY-NOTICES.txt.
| 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
Turns HTML pages, including their CSS styling and images, into PDF documents. Output looks the same on Windows, macOS, and Linux, since nothing else on the machine is needed to produce it. Supports inline styles, style blocks, and linked stylesheets, and embeds any images or SVG graphics used on the page. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.248.1122 | 186 | 9/5/2026 |
| 1.0.238.81 | 293 | 8/26/2026 |
| 1.0.165.124 | 822 | 6/14/2026 |
| 1.0.117 | 187 | 4/29/2026 |
| 1.0.102 | 147 | 4/14/2026 |