---
title: "onehtml"
url: https://recursiveai.org/onehtml/
description: "HTML and CSS libraries for .NET in pure C#. Parse HTML the way a browser does, edit it without disturbing a byte the edit didn’t touch, compute the accessibility tree Chromium exposes, and check pages for accessibility problems without a browser. MIT or Apache-2.0."
---

# onehtml

HTML and CSS for .NET, in pure C#. Parse HTML the way a browser does, edit it without disturbing a byte the edit didn’t touch, and check pages for accessibility without a browser.

```sh
dotnet add package RecursiveAI.OneHtml
```

- [Getting started](https://recursiveai.org/onehtml/docs/getting-started/)
- [Docs](https://recursiveai.org/onehtml/docs/)
- [Cookbook](https://recursiveai.org/onehtml/cookbook/)
- [Articles](https://recursiveai.org/onehtml/articles/)
- [GitHub](https://github.com/recursive-ai-oss/onehtml-csharp)
- [NuGet](https://www.nuget.org/packages/RecursiveAI.OneHtml)

## A quick look

Parse, query and edit. An edit changes only the bytes it touches, the result is re-parsed and verified, and the old snapshot stays valid.

[How editing works](https://recursiveai.org/onehtml/docs/editing/)

*Program.cs · C#*

```
using RecursiveAI.OneHtml;
using RecursiveAI.OneHtml.Editing;
Document doc = Document.Parse("<p>Hello <a href=/x>world</a>");
Node link = doc.Root.QuerySelector("a[href]");
EditResult edit = doc.Apply(new[] { Edit.SetAttribute(link, "title", "A link") });
byte[] output = edit.Document!.ToLosslessBytes();
```

### Parses like a browser

The WHATWG parser: encoding sniffing, the tokenizer and every insertion mode. It passes the html5lib tokenizer and tree-construction tests.

### Edits that leave the rest alone

Lossless editing of HTML, inline styles and stylesheets. Untouched bytes stay identical, and every result is re-parsed and verified.

### The accessibility tree Chromium exposes

WAI-ARIA 1.2, HTML-AAM and AccName 1.2, with Chromium’s choices written down. A reading view and navigation lists show what a screen-reader user meets.

### Accessibility checks without a browser

One rule catalogue covering the WCAG success criteria, suggested edits where exactly one fix exists, and axe-compatible and SARIF 2.1.0 output.

## 2.74× AngleSharp’s parsing speed

Parsing a 100-page sample of a crawled corpus from bytes, end to end, takes 125.0 ms per sweep, against 341.7 ms for AngleSharp 1.8.6 and 292.8 ms for HtmlAgilityPack 1.13.1. Measured with BenchmarkDotNet on .NET 10.

[The method and harness](https://github.com/recursive-ai-oss/onehtml-csharp/blob/v1.0.0/bench/README.md)

## The packages

- **RecursiveAI.OneHtml**: The HTML parser, the DOM as immutable snapshots with a source map, Selectors Level 4, a CSS parser, the cascade for every known property, and lossless editing of HTML and CSS.
- **.Accessibility**: `RecursiveAI.OneHtml.Accessibility` builds the accessibility tree, recomputes it after edits, and adds a reading view, navigation lists and tree diffs.
- **.Validation**: `RecursiveAI.OneHtml.Accessibility.Validation` checks pages against WCAG 2.0, 2.1 and 2.2 AA profiles and every W3C-approved ACT rule, with native JSON, axe-compatible JSON and SARIF output.
- **Conformance**: All 37 approved ACT rules implemented with 0 failing cases. A round trip with no edits is byte-identical on 18,330 of 18,330 corpus pages and stylesheets.
- **Safe by design**: Every input is treated as hostile. The libraries never read files or the network, and scripts are inert text.
- **Version**: 1.0.0. All three packages share one version.
- **.NET**: .NET 10. NativeAOT and trimming are supported, with no `unsafe` code. MIT or Apache-2.0.

## Go further

- [GitHub](https://github.com/recursive-ai-oss/onehtml-csharp)
- [NuGet](https://www.nuget.org/packages/RecursiveAI.OneHtml)
- [Getting started](https://recursiveai.org/onehtml/docs/getting-started/)
- [Cookbook](https://recursiveai.org/onehtml/cookbook/)
- [Editing](https://recursiveai.org/onehtml/docs/editing/)
- [The cascade](https://recursiveai.org/onehtml/docs/cascade/)
- [Accessibility tree](https://recursiveai.org/onehtml/docs/accessibility-tree/)
- [The checker](https://recursiveai.org/onehtml/docs/checker/)
- [WCAG coverage](https://recursiveai.org/onehtml/docs/coverage/)
- [Changelog](https://github.com/recursive-ai-oss/onehtml-csharp/blob/v1.0.0/CHANGELOG.md)
