---
title: "onehtml cookbook"
url: https://recursiveai.org/onehtml/cookbook/
description: "Short recipes for common onehtml tasks, each with complete code you can copy."
version: "1.0.0"
---

# onehtml cookbook

Short recipes for common onehtml tasks, each with complete code you can copy.

## Recipes

- [The accessibility tree of a page](https://recursiveai.org/onehtml/cookbook/accessibility-tree/index.md): Compute the tree a browser exposes to screen readers, with roles, accessible names, levels and hidden state, from HTML and CSS alone, and get the landmark…
- [Apply suggested accessibility fixes](https://recursiveai.org/onehtml/cookbook/apply-suggested-fixes/index.md): Take the edits the checker suggests for rules with exactly one correct fix, apply the ones you accept as lossless edits, and re-check only what changed.
- [Compute CSS styles for an element](https://recursiveai.org/onehtml/cookbook/computed-style-csharp/index.md): Get the computed value of any CSS property for an element, find the rule it came from, and recompute styles for a focused element or a narrow viewport…
- [Query HTML with CSS selectors](https://recursiveai.org/onehtml/cookbook/css-selectors/index.md): Find elements with QuerySelector, QuerySelectorAll, Matches and Closest using Selectors Level 4, including :has(), :is(), :not() with selector lists, and…
- [Detect the encoding of an HTML page](https://recursiveai.org/onehtml/cookbook/detect-encoding/index.md): Decode HTML bytes the way a browser does, using the byte order mark, the HTTP Content-Type header, the meta charset prescan and the windows-1252 fallback…
- [Edit HTML without reformatting it](https://recursiveai.org/onehtml/cookbook/edit-html-csharp-lossless/index.md): Change attributes, text and inline styles in an HTML file so that only the edited bytes change: quoting, character references, comments, whitespace and…
- [Extract all links and images from a page](https://recursiveai.org/onehtml/cookbook/extract-links-and-images/index.md): List every link and image on a page with its resolved URL, its attributes in source order, and the accessible name a screen reader announces for it.
- [Extract visible text from HTML](https://recursiveai.org/onehtml/cookbook/extract-visible-text/index.md): Get the readable text of a page without its script and style contents, either with a short walk over the text nodes or with the cascade-aware reading…
- [Parse HTML fragments](https://recursiveai.org/onehtml/cookbook/html-fragments/index.md): Parse a snippet of HTML, such as table rows or list items, in the context of the element it belongs in, so you get the elements a browser would create and…
- [Coming from AngleSharp: where the trees differ](https://recursiveai.org/onehtml/cookbook/migrate-from-anglesharp/index.md): If you are moving HTML parsing from AngleSharp to onehtml, this is what changes in the trees you get. On a corpus of real pages the two agree exactly on…
- [Parse and edit CSS](https://recursiveai.org/onehtml/cookbook/parse-and-edit-css/index.md): Parse a stylesheet into rules and declarations with source ranges, walk nested @media rules, and change a declaration or add a rule without reformatting…
- [Parse HTML from a string, file or stream](https://recursiveai.org/onehtml/cookbook/parse-html/index.md): Load HTML into a document from a string, a file or a stream, let the parser pick the encoding from the bytes, and see the tokenizer’s parse errors when…
- [Remove scripts and event handlers](https://recursiveai.org/onehtml/cookbook/remove-scripts/index.md): Strip script elements, inline event-handler attributes and javascript: links from a page with lossless edits, and know where this stops: onehtml has no…
- [Save edits as JSON and replay them](https://recursiveai.org/onehtml/cookbook/save-and-replay-edits/index.md): Store edits in the versioned onehtml-edits JSON format and apply them to another copy of the page later. Replay finds each target again or reports why it…
- [Run WCAG checks in CI with SARIF output](https://recursiveai.org/onehtml/cookbook/wcag-checks-ci-sarif/index.md): Check every HTML file of a built site against WCAG 2.2 AA without a browser, write one SARIF 2.1.0 file per page for your code-scanning tool, and fail the…
