# onehtml Go docs, all pages (onehtml-go 1.1.1) Every page of https://recursiveai.org/onehtml/go/docs/ and https://recursiveai.org/onehtml/go/cookbook/ as markdown, getting started first. Index: https://recursiveai.org/onehtml/go/llms.txt # Getting started with onehtml for Go Install onehtml for Go, parse HTML and query it with CSS selectors, read computed styles, edit a page losslessly, build the accessibility tree and check a page against WCAG. onehtml for Go parses HTML into the tree a browser builds, matches CSS selectors against it, computes the cascade, and builds the accessibility tree a browser gives screen readers. It does no layout and no painting, opens no files, makes no network requests and never runs script. Every sample on this page was compiled and run with Go 1.26.8 against `recursiveai.org/go/onehtml` v1.1.1 from the Go module proxy; the output under each one is what it printed. ## Install onehtml needs Go 1.24 or newer. ```sh mkdir html-start && cd html-start go mod init example.com/html-start go get recursiveai.org/go/onehtml@v1.1.1 ``` The import path is `recursiveai.org/go/onehtml` and the package name is `onehtml`. The accessibility tree is in `recursiveai.org/go/onehtml/accessibility` and the checker in `recursiveai.org/go/onehtml/accessibility/validation`. The module has no dependencies outside the standard library, no cgo and no `unsafe`. The license is MIT or Apache-2.0, at your choice. Each sample is a complete `main.go`. ## Parse and select `Parse` reads from an `io.Reader` and `ParseBytes` from a byte slice. `Select` and `SelectFirst` take Selectors Level 4. ```go package main import ( "fmt" "log" "strings" "recursiveai.org/go/onehtml" ) const page = ` Shop ` func main() { doc, err := onehtml.Parse(strings.NewReader(page)) if err != nil { log.Fatal(err) } links, err := doc.Select("nav a[href]") if err != nil { log.Fatal(err) } for _, a := range links { href, _ := a.Get("href") fmt.Printf("%-5s %s\n", a.TextContent(), href) } items, err := doc.Select("ul.items > li") if err != nil { log.Fatal(err) } for _, li := range items { price, _ := li.Get("data-price") fmt.Printf("%q costs %s\n", strings.TrimSpace(li.TextContent()), price) } // The parser closes the
  • elements and adds , and , as a browser does. fmt.Println(items[0].OuterHTML()) fmt.Println(len(doc.Errors()), "parse errors") } ``` ```text Home / Help https://example.com/help "Tea" costs 4.50 "Coffee & beans" costs 12
  • Tea
  • 0 parse errors ``` - Malformed markup is not an error: whatever the bytes, the result is the tree a browser builds. The parse errors the HTML standard lists are in `doc.Errors()`, with their positions. - `TextContent` decodes entities, so `&` reads as `&`. `OuterHTML` and `InnerHTML` serialize as the standard says. - A `Node` is a small value you can copy freely. `Children`, `Descendants` and `Ancestors` are iterators and never recurse, so deep documents can’t exhaust the stack. `CompileSelector` compiles a selector once for reuse. ## Computed styles `doc.Style()` runs the cascade: the HTML standard’s default style sheet, `

    Read me

    ` func main() { doc, err := onehtml.Parse(strings.NewReader(page)) if err != nil { log.Fatal(err) } p, err := doc.SelectFirst("p.note") if err != nil { log.Fatal(err) } cs := doc.Style().ComputedStyle(p) // a 1280 x 720 screen by default for _, prop := range []string{"color", "font-family", "font-weight", "line-height", "padding-left", "display"} { src, _ := cs.Source(prop) from := src.Selector switch { case src.Inherited: from = "inherited" case src.Initial: from = "initial value" case src.Origin == onehtml.OriginUserAgent: from = "default style sheet" case from == "": from = "style attribute" } fmt.Printf("%-13s %-24s %s\n", prop, cs.Get(prop), from) } // The same page on a phone: the media query now matches. phone := doc.Style(onehtml.WithStyleContext(onehtml.StyleContext{ViewportWidth: 390, ViewportHeight: 844})) fmt.Println("display at 390px:", phone.ComputedStyle(p).Get("display")) } ``` ```text color rgb(102, 51, 153) .note font-family "Open Sans", sans-serif inherited font-weight 700 style attribute line-height 24px inherited padding-left 16px .note display block default style sheet display at 390px: none ``` - Values read back in the forms browsers report: colors as `rgb()`, lengths in px, `bold` as `700`. `Source` says which rule, attribute or inherited value won. - The default context is a 1280 × 720 light-scheme screen. `WithStyleContext` sets the viewport, print, dark scheme, reduced motion and the other media features. - There is no layout, so values that need it, such as a percentage width, stay as specified. Linked style sheets come from you through `WithStylesheets`; the library never fetches one. ## Edit a page without touching the rest `Rewrite` turns a list of edits into bytes, splicing each one into the original input. Everything else comes back exactly as it was. ```go package main import ( "fmt" "log" "strings" "recursiveai.org/go/onehtml" ) // Hand-written markup: unquoted and single-quoted attributes, upper case, a comment, no

    . const page = `

    Hello, world Example ` func main() { doc, err := onehtml.Parse(strings.NewReader(page)) if err != nil { log.Fatal(err) } var edits []onehtml.Edit links, _ := doc.Select("a[target=_blank]") for _, a := range links { edits = append(edits, onehtml.SetAttribute(a, "rel", "noopener")) } imgs, _ := doc.Select("img:not([alt])") for _, img := range imgs { edits = append(edits, onehtml.SetAttribute(img, "alt", "A cat")) } b, _ := doc.SelectFirst("b") edits = append(edits, onehtml.ReplaceText(b.FirstChild(), "Go")) res := onehtml.Rewrite(doc, edits) if !res.Applied() { log.Fatal(res.Reasons) } fmt.Println(string(res.Document)) fmt.Println(len(res.Ranges), "ranges rewritten, checked by", res.Verifications, "reparse") // No edits: the output is the input, byte for byte. same := onehtml.Rewrite(doc, nil) fmt.Println("unchanged:", string(same.Document) == page) } ``` ```text

    Hello, Go Example A cat 3 ranges rewritten, checked by 1 reparse unchanged: true ``` - The upper-case tags, unquoted attributes, the comment and the missing `

    ` are all still there. The output is parsed again to check that it gives the tree the edits should have made. - All edits apply or none does; `res.Outcomes` and `res.Reasons` say what happened to each one. - `doc.Apply` and `doc.Edit` make the same edits on a new snapshot of the tree instead of bytes, and report a `ChangeSet` per commit. The old snapshot stays readable. ## The accessibility tree `accessibility.Tree` builds the tree a browser exposes to assistive technology, with roles, names and states. ```go package main import ( "fmt" "log" "strings" "recursiveai.org/go/onehtml" "recursiveai.org/go/onehtml/accessibility" ) const page = `Sign in

    Sign in

    ` func main() { doc, err := onehtml.Parse(strings.NewReader(page)) if err != nil { log.Fatal(err) } tree, err := accessibility.Tree(doc) if err != nil { log.Fatal(err) } walk(tree.Root(), 0) } // walk walks the tree as assistive technology sees it: Exposed skips ignored nodes, // such as the hidden div, and text nodes are left out here. func walk(n accessibility.Node, depth int) { if !n.IsText() { fmt.Printf("%s%s %q\n", strings.Repeat(" ", depth), n.ChromeRole(), n.Name()) depth++ } for c := range n.Exposed() { walk(c, depth) } } ``` ```text RootWebArea "Sign in" banner "" navigation "Main" link "Home" main "" heading "Sign in" form "" LabelText "" textbox "Email" button "Continue" ``` - `Role` is the computed ARIA role; `ChromeRole` is the role as Chrome reports it, including its internal roles such as `LabelText`. The text field takes its name, “Email”, from the label around it. - The `hidden` div isn’t exposed. Ignored nodes, such as the `` and `` elements, stay in the tree with their reasons (`IgnoredReasons`); `Exposed` steps over them. - `tree.ReadingView()` and `tree.NavigationLists()` give the page as a reading order and as lists of headings, landmarks, links, form fields and tables. ## Check a page against WCAG `validation.Check` runs the built-in rules. `WithProfile` limits them to one WCAG version and level. ```go package main import ( "fmt" "log" "os" "strings" "recursiveai.org/go/onehtml" "recursiveai.org/go/onehtml/accessibility/validation" ) const page = `Gallery

    Gallery

    Light grey text

    ` func main() { doc, err := onehtml.Parse(strings.NewReader(page)) if err != nil { log.Fatal(err) } report, err := validation.Check(doc, validation.WithProfile(validation.ProfileWCAG22AA)) if err != nil { log.Fatal(err) } fmt.Println(report.Count(validation.Failed), "failed,", report.Count(validation.Passed), "passed,", report.Count(validation.CantTell), "can't tell") for res := range report.WithOutcome(validation.Failed) { fmt.Printf("%-24s %-11s %-9s <%s>\n", res.RuleID, strings.Join(res.Rule.Criteria, " "), res.Rule.Impact, res.Target.Name()) } // SARIF for code scanning; WriteJSON, WriteAxeJSON and WriteEARL work the same way. f, err := os.Create("report.sarif") if err != nil { log.Fatal(err) } defer f.Close() if err := report.WriteSARIF(f); err != nil { log.Fatal(err) } } ``` ```text 4 failed, 5 passed, 4 can't tell color-contrast 1.4.3 serious

    html-has-lang 3.1.1 serious image-alt 1.1.1 critical link-name 2.4.4 4.1.2 serious ``` - Each result names the rule, the WCAG success criteria it checks and its impact. The contrast of `#aaa` on white is below 4.5:1. - “Can’t tell” means a person has to judge, as with whether the title describes the page, or the answer depends on layout, as with `target-size`. `accessibility.ParseFacts` and `validation.WithFacts` take rendered facts from a browser to settle the layout ones. - `WriteJSON`, `WriteAxeJSON`, `WriteSARIF` and `WriteEARL` export the report. ## Registered custom properties and font metrics New in 1.1: `@property` rules are applied, invalid declarations are reported, and `WithFontMetrics` gives the `ex`, `ch`, `cap` and `ic` units real values. ```go package main import ( "fmt" "log" "strings" "recursiveai.org/go/onehtml" ) const page = `

    Inside

    ` func main() { doc, err := onehtml.Parse(strings.NewReader(page)) if err != nil { log.Fatal(err) } // The caller measures fonts; here a zero advance of 0.55 em for every font. metrics := func(q onehtml.FontQuery) onehtml.FontMetrics { return onehtml.FontMetrics{ZeroAdvance: 0.55} } styles := doc.Style(onehtml.WithFontMetrics(metrics)) for _, r := range styles.Registrations() { fmt.Printf("@property %s %s inherits=%v initial=%s\n", r.Name, r.Syntax, r.Inherits, r.InitialValue) } for _, sel := range []string{".card", ".card p", ".bad"} { n, _ := doc.SelectFirst(sel) cs := styles.ComputedStyle(n) fmt.Printf("%-7s --gap %-4s padding-top %-4s width %s\n", sel, cs.Get("--gap"), cs.Get("padding-top"), cs.Get("width")) } // Declarations that won the cascade but have no value at computed-value time. for n, bad := range styles.InvalidDeclarations() { fmt.Printf("<%s> %s: %s (from %s)\n", n.Name(), bad.Property, bad.Value, bad.Source.Selector) } } ``` ```text @property --gap inherits=false initial=8px .card --gap 3px padding-top 3px width 176px .card p --gap 8px padding-top 8px width auto .bad --gap 8px padding-top 8px width auto

    margin: var(--missing) (from .card p)

    --gap: red (from .bad) ``` - `--gap` is registered as a ``, so `calc(1px + 2px)` computes to `3px`. It doesn’t inherit, so the `

    ` inside the card gets the initial `8px`, and `red` doesn’t fit the syntax, so `.bad` gets `8px` too. - With the font metrics, `20ch` at 16px is 20 × 0.55 × 16 = `176px`. Without them, `ch` is estimated at half an em. - `InvalidDeclarations` lists the declarations that won the cascade but have no value at computed-value time, with their source. `ComputedStyle.InvalidDeclarations` does the same for one element. ## Where next - [Overview](https://recursiveai.org/onehtml/go/docs/overview/): the README, with the quick start and the packages. - [Changelog](https://recursiveai.org/onehtml/go/docs/changelog/): what changed in 1.1.0 and 1.1.1. - [Package documentation](https://pkg.go.dev/recursiveai.org/go/onehtml) on pkg.go.dev, with an example for each feature. # onehtml **A pure-Go HTML and CSS library that parses HTML exactly as a browser does, matches Selectors Level 4, computes the CSS cascade, edits a page without disturbing a byte the edit didn't touch, and builds the accessibility tree a browser gives screen readers.** It also checks pages against every WCAG level, from the standard library alone. ## Why onehtml - **Browser-exact parsing.** The WHATWG tokenizer and tree builder in full, fragments and parse errors included, with the Encoding Standard's detection and decoders. Every node and attribute knows its byte range in the original input. - **Selectors and cascade.** Selectors Level 4 compiled once and matched without recursion; origins, layers, `@scope`, nesting, `@media`, `var()` and `calc()`, with computed values serialized as `getComputedStyle` gives them. No layout, no painting. - **Lossless editing.** `Rewrite` splices edits into the original bytes and verifies the result by parsing it again; with no edits the output is byte-identical to the input. - **Accessibility.** The accessibility tree (WAI-ARIA 1.2, HTML-AAM, Accessible Name and Description 1.2), a reading view and navigation lists, and a checker for WCAG 2.0, 2.1 and 2.2 with suggested fixes and JSON, axe-compatible JSON, SARIF and EARL exports. - **Safe on hostile input.** No panic and no hang on any bytes; limits are checked before the work they guard, and nothing recurses on input depth. - **Never fetches, never executes.** The library opens no files and makes no network requests; linked stylesheets come from the caller and scripts are inert text. Standard library only, no cgo, no `unsafe`. ## Install ``` go get recursiveai.org/go/onehtml ``` Go 1.24 or newer. ## Quick start ```go doc, err := onehtml.Parse(strings.NewReader(`

    `)) if err != nil { log.Fatal(err) } links, err := doc.Select("nav a[href^='https://']") if err != nil { log.Fatal(err) } styles := doc.Style() for _, a := range links { href, _ := a.Get("href") fmt.Println(a.TextContent(), href, styles.ComputedStyle(a).Get("color")) } res := onehtml.Rewrite(doc, []onehtml.Edit{onehtml.SetAttribute(links[0], "rel", "noopener")}) if !res.Applied() { log.Fatal(res.Reasons) } fmt.Println(string(res.Document)) // the original bytes, changed only at the edit ``` The same example runs as `Example_quickStart` in the package documentation. ## Where to go - [`onehtml`](https://pkg.go.dev/recursiveai.org/go/onehtml): parser, DOM, selectors, cascade and editing, with an `Example` for each. - [`onehtml/accessibility`](https://pkg.go.dev/recursiveai.org/go/onehtml/accessibility): `accessibility.Tree(doc)`, the reading view and navigation lists. - [`onehtml/accessibility/aria`](https://pkg.go.dev/recursiveai.org/go/onehtml/accessibility/aria): the WAI-ARIA roles, states and properties with their characteristics. - [`onehtml/accessibility/validation`](https://pkg.go.dev/recursiveai.org/go/onehtml/accessibility/validation): `validation.Check(doc)`, profiles, rules and exports. - [Conformance](https://recursiveai.org/onehtml/go/docs/conformance/): results against the onehtml conformance kit. - [Performance](https://recursiveai.org/onehtml/go/docs/performance/): parse and select against x/net/html and cascadia, and floors for the rest. - [Changelog](https://recursiveai.org/onehtml/go/docs/changelog/) and [security policy](https://github.com/recursive-ai-oss/onehtml-go/blob/b6b36a3de36130cf715d83198af600c71d30c3f2/SECURITY.md). ## Licence Licensed under either of MIT or Apache-2.0 at your option (`LICENSE-MIT`, `LICENSE-APACHE`). Third-party data is listed in `THIRD-PARTY-NOTICES.md`. Copyright Recursive AI, LLC. # Conformance The library is checked against the onehtml conformance kit, a language-neutral suite of cases taken from the specifications' own test suites (html5lib-tests, WHATWG and CSS working group tests, WPT, W3C ACT rules, axe-core outcomes, Chrome accessibility captures) and our own. Results of this library through the kit's adapter, with the C# onehtml library for comparison. A case the library does not follow is a recorded deviation with its reason; "unsupported" means the case needs something the library by design does not do (running script, layout, a rendered page). | Suite | Cases | Pass | Partial | Deviation | Unsupported | Fail | C# library: pass | |---|---:|---:|---:|---:|---:|---:|---:| | a11y-export | 1553 | 1553 | 0 | 0 | 0 | 0 | 1543 | | a11y-tree | 3796 | 3734 | 0 | 42 | 20 | 0 | 3409 | | aria-taxonomy | 217 | 217 | 0 | 0 | 0 | 0 | 150 | | cascade | 1567 | 1544 | 0 | 3 | 20 | 0 | 1299 | | catalogue | 461 | 448 | 0 | 0 | 13 | 0 | 446 | | check | 121 | 119 | 0 | 2 | 0 | 0 | 119 | | css-condition | 210 | 210 | 0 | 0 | 0 | 0 | 209 | | css-keyframes | 142 | 142 | 0 | 0 | 0 | 0 | 141 | | css-syntax | 543 | 543 | 0 | 0 | 0 | 0 | 542 | | css-update | 124 | 124 | 0 | 0 | 0 | 0 | 123 | | css-value | 1793 | 1790 | 0 | 3 | 0 | 0 | 1784 | | dom | 367 | 367 | 0 | 0 | 0 | 0 | 366 | | edit | 558 | 558 | 0 | 0 | 0 | 0 | 550 | | encoding | 2129 | 2129 | 0 | 0 | 0 | 0 | 1121 | | export | 87 | 87 | 0 | 0 | 0 | 0 | 86 | | mutate | 182 | 180 | 0 | 2 | 0 | 0 | 179 | | navigation | 142 | 142 | 0 | 0 | 0 | 0 | 125 | | parse | 11322 | 11315 | 0 | 1 | 6 | 0 | 11316 | | reading-view | 62 | 62 | 0 | 0 | 0 | 0 | 59 | | rendered-facts | 91 | 91 | 0 | 0 | 0 | 0 | 90 | | select | 2184 | 2180 | 0 | 0 | 4 | 0 | 2167 | | serialize | 103 | 103 | 0 | 0 | 0 | 0 | 103 | | source-map | 60 | 60 | 0 | 0 | 0 | 0 | 59 | | validate | 1220 | 746 | 227 | 32 | 215 | 0 | 713 | | **total** | **29034** | **28444** | **227** | **85** | **278** | **0** | **26699** | No case fails. A *partial* validate case is one where the library reports "cannot tell" and the expected answer is a verdict (ACT Rules Format 1.1, section 4.14). Unsupported parse and a11y-tree cases run script. Unsupported cascade cases need layout or container-query sizes. Unsupported select cases use the column combinator, which matches only with table layout. Unsupported validate cases are for rules the library does not implement or that need a rendered page, script, frames or several pages; the catalogue rows for those rules are unsupported too. # Performance One machine, one day, indicative of relative speed rather than a promise: AMD Ryzen 9 7950X3D (16 cores, 32 threads), Linux 7.0, Go 1.26.8, 2026-12-01, run alone on the machine (load average 1.3 before, 1.0 to 2.1 during, 1.6 after), GOMAXPROCS 32. Each figure is the median of three runs of `go test -bench -benchmem -count 3`. The corpus is six generated pages in `bench/testdata` ([`bench/README.md`](https://github.com/recursive-ai-oss/onehtml-go/blob/b6b36a3de36130cf715d83198af600c71d30c3f2/bench/README.md)). Before any row counts, a test builds both libraries' trees (or match lists) for every page and requires them to be identical; they are. **Parse**, `ParseBytes` against x/net/html (v0.38.0, the faster of the two versions measured; v0.63.0 is slower still), scripting off in both: | Page | Size | onehtml MB/s | x/net/html MB/s | Speed-up | onehtml B/op, allocs | x/net/html B/op, allocs | |---|---:|---:|---:|---:|---:|---:| | article, small | 16 KB | 156 | 102 | 1.5x | 121 KB, 80 | 157 KB, 1,910 | | article, medium | 165 KB | 147 | 83 | 1.8x | 1.29 MB, 372 | 1.77 MB, 22,196 | | article, large | 978 KB | 164 | 85 | 1.9x | 8.6 MB, 1,889 | 10.6 MB, 132,446 | | product listing | 192 KB | 178 | 109 | 1.6x | 1.80 MB, 78 | 1.62 MB, 25,482 | | reference page | 165 KB | 145 | 92 | 1.6x | 1.17 MB, 526 | 1.70 MB, 19,821 | | legacy markup | 224 KB | 104 | 92 | 1.1x | 2.16 MB, 703 | 2.35 MB, 29,426 | onehtml also keeps the original bytes, the byte range of every node and attribute, and the parse errors, which x/net/html does not. **Select**, twenty typical selectors (types, ids, classes, attributes, combinators, `:nth-child`, `:not`, `:has`), compiled and matched, against cascadia v1.3.3 on x/net/html trees: | Page | Compile and match | | Match only | | |---|---:|---:|---:|---:| | | onehtml | cascadia | onehtml | cascadia | | article, medium | 1.35 ms | 2.18 ms | 1.39 ms | 2.16 ms | | product listing | 0.61 ms | 0.99 ms | 0.64 ms | 0.98 ms | | reference page | 1.48 ms | 2.33 ms | 1.51 ms | 2.34 ms | One selector at a time, onehtml is faster on seventeen of twenty and level on two (`#s17`, `.sec`); `section:has(table)` is 20% slower. **Rows without a Go competitor**, against floors, single goroutine, on the medium article page (6,330 elements) unless stated: | Row | Result | Floor | |---|---:|---:| | Cascade: style every element (sheets parsed, three properties read each) | 609,000 elements/s | 300,000 | | Accessibility tree, `accessibility.Tree` (includes the cascade) | 251,000 elements/s | 50,000 | | Full check, `validation.Check`, every rule | 76,000 elements/s | 25,000 | | `Rewrite` of three edits, verified by re-parsing | 70 MB/s (65 MB/s on the 978 KB page) | 20 MB/s | | `Restyle` after a one-class edit, 7,005-element page | 13 µs (a full restyle: 9.4 ms) | 1 ms | # Changelog All notable changes to this library are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project follows [Semantic Versioning](https://semver.org/). ## [1.1.1] - 2026-12-03 ### Added - `ComputedStyle.SpecifiedDisplay`: the element's `display` as declared, in the short form `Get` uses, before blockification. A float, an absolutely positioned element, the root element and a flex or grid item compute to a block-level `display` (CSS Display 3 section 2.7), so `Get("display")` on a float declared `inline-flex` reads `flex`; `SpecifiedDisplay` still reads `inline-flex`, which tells a caller the inner display type. ### Fixed - `steps()` keeps `jump-start`, `jump-none` and `jump-both` as written when serialized (`steps(2, jump-start)`, no longer `steps(2, start)`); `jump-end` and `end` still read as `steps(2)`. - `object-position` takes a unitless `0` as the offset in its three- and four-value forms (`top 0 right 1px` is `calc(100% - 1px) 0px`, no longer refused and reset to `50% 50%`). - `background-size` computes as browsers report it: a single value is the value and `auto` (`10px` is `10px auto`), two `auto`s are `auto`, and lengths are in px (`1em` is `16px auto`). A negative or malformed size is invalid. - The `background-*` longhand lists (`background-position-x` and `-y`, `-size`, `-repeat`, `-clip`, `-origin`, `-attachment`, `-blend-mode`) read back as long as the `background-image` list: a longer list is cut, and a shorter one repeats from its start (`background-position: left, right` with one image reads `0%` for `background-position-x`). ### Notes - The initial `font-family` stays `serif`. Browsers take it from the platform's default font settings, so it is not fixed by a standard; callers that need another default set `font-family` on the root. ## [1.1.0] - 2026-12-03 ### Added - `Styles.Registrations` and `PropertyRegistration`: the document's `@property` rules (CSS Properties and Values API 1). A registered custom property now takes its initial value when nothing sets it, does not inherit when `inherits` is false, and has a value that does not match its syntax treated as unset; a matching value is computed to its canonical form (`calc(1px + 2px)` is `3px`). `ResolveAnimations` reports a registered custom property that a keyframe sets, so a caller can interpolate it by its syntax. - `font` takes the system font keywords (`caption`, `icon`, `menu`, `message-box`, `small-caption`, `status-bar`), as Chrome reports them on Linux: a 16px Arial in the normal style and weight. - The `table` element's `border` attribute sets the four border widths (1px when the value does not parse). - `WithFontMetrics`, `FontQuery`, `FontMetrics` and `FontMetricsFunc`: the caller measures the primary font, and the `ex`, `ch`, `cap` and `ic` units (and the root-relative `rex`, `rch`, `rcap` and `ric`) take its x-height, zero advance, cap height and ideograph advance. Without it, or for a measurement the function leaves at zero, the estimates stay (half an em, 0.7 em, one em). `font-size` in `ex` is relative to the parent's font. - `ComputedStyle.InvalidDeclarations` and `Styles.InvalidDeclarations`, with `InvalidDeclaration`: the declarations that won the cascade but are invalid at computed-value time (a `var()` that does not fit the property, a shorthand that does not expand after substitution, a custom property that refers to nothing or does not fit its registered syntax), with their source. ### Changed - Several computed values now read back in the forms browsers report, so code that compared serialized values from 1.0.0 sees new strings: multi-word `font-family` names are quoted, `font-stretch` is a percentage, a numeric `line-height` reads as px through `Get` (descendants still inherit the number), animation times are in seconds, `object-position` and `background-position-x`/`-y` keywords become percentages, and px lengths are written with six significant digits. Details under Fixed. ### Fixed - Media features with a length now match in `vw`, `vh`, `vmin`, `vmax` (and the small, large and dynamic forms) and with `calc()`, `min()`, `max()` and `clamp()`, including on the left of a range: `(min-width: 50vw)`, `(min-width: calc(400px + 400px))`. - `width: calc(50% - 10px)` no longer drops the length term of a sum with a percentage in a non-negative property. - The default style sheet no longer sets `unicode-bidi: bidi-override` on every element: that block applies to ISO-8859-8 documents only. Block elements are `isolate` and `bdo` is `isolate-override`, as the HTML Standard's rules say. - The default style sheet's table rules apply "only if border is not equivalent to zero": cells of `table[border=0]` no longer get a 1px inset border. - Medium `monospace` is 13px: a font family list that is the generic `monospace` alone uses the fixed default size (`pre`, `code`, `kbd`, `samp`, `tt`), with the keyword scale of that size, and `em`, `larger`, `smaller` and inheritance under a parent that is not monospace start from the parent's size scaled to it. `ui-monospace`, named families and lists with other families keep 16px. - `columns`, `grid-area`, `grid-row` and `grid-column` set their longhands. `place-content`, `place-items` and `place-self` keep `safe` and `unsafe`. `font-variant` and `font-synthesis` are expanded, and `font` resets the `font-variant-*` longhands instead of inheriting them. `column-width` has the initial value `auto`. - `var()` in `padding-inline`, `padding-block`, `margin-inline`, `margin-block`, `inset-inline`, `inset-block` and the `border-inline-*` and `border-block-*` shorthands now substitutes into the physical longhands. - A quoted `url('...')` in the `background` shorthand (a data: URL included) no longer makes `background-image` compute to `none`. - `animation-delay` reads back the delay list, also when set through the `animation` shorthand. - In `ResolveAnimations`, `box-shadow` is one animated property (not its `box-shadow-*` longhands) and `font-stretch` keeps that name (not `font-width`). - The default style sheet is regenerated from the current HTML Standard text. - `word-spacing` takes a percentage and keeps it in the computed value. - `border-*-width: inherit` takes the width the parent specified, not the 0 the parent reads when it has no border style (the child's own style still decides whether the width applies); with nothing specified above it is `medium`, 3px. - `align-items` and `justify-items` refuse `anchor-center` (`align-self` and `justify-self` keep it); `page` takes an identifier and refuses a string; `text-transform` takes `none`, `capitalize`, `uppercase` and `lowercase` alone, so `full-width` and `full-size-kana` are invalid, as in Chrome 156. - An unquoted `font-family` name of several words that starts with a generic family or a CSS-wide keyword (`serif x`) is invalid, and the declaration is dropped; `x serif` is still a family name. - Easing functions serialize as browsers do: `steps(4, end)` is `steps(4)`, `step-start` is `steps(1, start)`, `step-end` is `steps(1)`, and `linear()` lists every stop with its input (`linear(0 0%, 0.5 50%, 1 100%)`; a stop with two inputs becomes two stops). - `object-position` computes as a position: keywords become percentages, an offset from the right or bottom edge becomes `calc(100% - 10px)`, lengths are in px, and a `calc()` sum puts the percentage first. - `text-align` takes `-webkit-left`, `-webkit-center` and `-webkit-right`; the default sheet makes `center` and `caption` `-webkit-center`, and `th` centred unless its parent aligns text some other way. The engine keyword `-internal-center` stands for that last rule and is accepted from any source. - `text-indent` takes `hanging` and `each-line`, in either order, and computes them after the length. - The color scheme of an element decides its system colors and `light-dark()`: `color-scheme` is read (`normal` is light; `dark` is dark; `light dark` follows the host's preference; `only` is kept and serialized last). An element without `color-scheme` stays light under a dark host, as Chrome does. The initial `color` follows the scheme of the root element. - The system colors have Chrome's values (`ButtonBorder` black, `Highlight` `rgba(0, 65, 198, 0.8)`, `SelectedItem` `#1967d2`, `GrayText` gray), and the deprecated system colors compute as CSS Color 4 section 6.3 maps them (`Menu`, `Window`, `InfoBackground`, `Background` are `Canvas`; `ThreeDFace` and `ButtonHighlight` are `ButtonFace`; `ActiveBorder` and `WindowFrame` are `ButtonBorder`; `WindowText` is `CanvasText`), in the light and dark scheme. - The default style sheet's `table[border]` rules read the attribute as an integer: `border=05` is a border of 5, `border=" 0"` and `border=0px` are none. Their specificity is that of `table[border]`, so `table[frame]` rules after them win again. - `font-family` prints a family name that is more than one word, or that needs escaping, as a quoted string (`"Open Sans", fantasy`, `"Times New Roman"`), as browsers do; a single identifier stays bare, also when it was quoted. - `font-stretch` computes to a percentage (`condensed` is `75%`, `normal` is `100%`), also through the `font` shorthand. - A numeric `line-height` reads as the length it multiplies out to under the element's font size (`1.5` at 16px is `24px`), also through the `font` shorthand; descendants still inherit the number. - `animation-duration` with no duration computes to `0s` for an animation on the document timeline (it stays `auto` with a scroll, view or `none` timeline), and `animation-delay` is written in seconds (`100ms` is `0.1s`). - `background-position-x` and `-y` compute as positions: keywords are percentages, `0` is `0px`, an offset from the right or bottom edge is `calc(100% - 10px)`, and a sum puts the percentage first. - Registered custom properties compute `` to `deg`, `