Keep your coding agent up to date with the latest web best practices
Release v0.0.192
github-actions[bot]650eb8361913
diff --git a/.agents/plugins/marketplace.json b/.agents/plugins/marketplace.jsonindex 9ebd271..09eecd3 100644--- a/.agents/plugins/marketplace.json+++ b/.agents/plugins/marketplace.json@@ -15,7 +15,7 @@"authentication": "ON_INSTALL"},"category": "Developer Tools",- "version": "0.0.191"+ "version": "0.0.192"}]}diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.jsonindex 58113e4..d1045d7 100644--- a/.claude-plugin/marketplace.json+++ b/.claude-plugin/marketplace.json@@ -8,7 +8,7 @@"name": "modern-web-guidance","source": "./","description": "Keep your coding agent up to date with the latest web best practices",- "version": "0.0.191"+ "version": "0.0.192"}]}diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonindex 6291184..d607fb9 100644--- a/.claude-plugin/plugin.json+++ b/.claude-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "modern-web-guidance","description": "Keep your coding agent up to date with the latest web best practices",- "version": "0.0.191",+ "version": "0.0.192","author": {"name": "Google Chrome"}diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.jsonindex 066e8a6..9fea550 100644--- a/.codex-plugin/plugin.json+++ b/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "modern-web-guidance",- "version": "0.0.191",+ "version": "0.0.192","description": "Keep your coding agent up to date with the latest web best practices","author": {"name": "Google Chrome",diff --git a/.cursor-plugin/plugin.json b/.cursor-plugin/plugin.jsonindex 97907a9..93842cd 100644--- a/.cursor-plugin/plugin.json+++ b/.cursor-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "modern-web-guidance","description": "Modern Web Guidance is an agent skill and CLI tool designed to help AI coding agents build web applications using modern, secure, and high-performance APIs rather than outdated workarounds. Supported by the Google Chrome team, it injects expert-curated web platform best practices directly into an agent's context window to prevent the generation of bloated, legacy code.",- "version": "0.0.191",+ "version": "0.0.192","author": {"name": "Google Chrome"}diff --git a/.github/plugin/plugin.json b/.github/plugin/plugin.jsonindex 97907a9..93842cd 100644--- a/.github/plugin/plugin.json+++ b/.github/plugin/plugin.json@@ -1,7 +1,7 @@{"name": "modern-web-guidance","description": "Modern Web Guidance is an agent skill and CLI tool designed to help AI coding agents build web applications using modern, secure, and high-performance APIs rather than outdated workarounds. Supported by the Google Chrome team, it injects expert-curated web platform best practices directly into an agent's context window to prevent the generation of bloated, legacy code.",- "version": "0.0.191",+ "version": "0.0.192","author": {"name": "Google Chrome"}diff --git a/.grok-plugin/marketplace.json b/.grok-plugin/marketplace.jsonindex 58113e4..d1045d7 100644--- a/.grok-plugin/marketplace.json+++ b/.grok-plugin/marketplace.json@@ -8,7 +8,7 @@"name": "modern-web-guidance","source": "./","description": "Keep your coding agent up to date with the latest web best practices",- "version": "0.0.191"+ "version": "0.0.192"}]}diff --git a/README.md b/README.mdindex 0199317..9b87e47 100644--- a/README.md+++ b/README.md@@ -85,76 +85,97 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro#### The full list<details>-<summary><strong>130 modern web features</strong></summary>+<summary><strong>190 modern web features</strong></summary>-### CSS & Layout (58 features)+### CSS & Layout (108 features)| | | || :--- | :--- | :--- |-| [::backdrop](https://web-platform-dx.github.io/web-features-explorer/features/backdrop/) | [Cross-document view transitions](https://web-platform-dx.github.io/web-features-explorer/features/cross-document-view-transitions/) | [Scroll-driven animations](https://web-platform-dx.github.io/web-features-explorer/features/scroll-driven-animations/) |-| [:has()](https://web-platform-dx.github.io/web-features-explorer/features/has/) | [Custom highlights](https://web-platform-dx.github.io/web-features-explorer/features/highlight/) | [scroll-initial-target](https://web-platform-dx.github.io/web-features-explorer/features/scroll-initial-target/) |-| [:host-context()](https://web-platform-dx.github.io/web-features-explorer/features/host-context/) | [field-sizing](https://web-platform-dx.github.io/web-features-explorer/features/field-sizing/) | [scroll-target-group](https://web-platform-dx.github.io/web-features-explorer/features/scroll-target-group/) |-| [:not()](https://web-platform-dx.github.io/web-features-explorer/features/not/) | [font-size-adjust](https://web-platform-dx.github.io/web-features-explorer/features/font-size-adjust/) | [scrollbar-color](https://web-platform-dx.github.io/web-features-explorer/features/scrollbar-color/) |-| [:user-valid and :user-invalid](https://web-platform-dx.github.io/web-features-explorer/features/user-pseudos/) | [image-set()](https://web-platform-dx.github.io/web-features-explorer/features/image-set/) | [scrollbar-width](https://web-platform-dx.github.io/web-features-explorer/features/scrollbar-width/) |-| [@function](https://web-platform-dx.github.io/web-features-explorer/features/function/) | [Individual transform properties](https://web-platform-dx.github.io/web-features-explorer/features/individual-transforms/) | [scrollend](https://web-platform-dx.github.io/web-features-explorer/features/scrollend/) |-| [@starting-style](https://web-platform-dx.github.io/web-features-explorer/features/starting-style/) | [interpolate-size](https://web-platform-dx.github.io/web-features-explorer/features/interpolate-size/) | [scrollIntoView()](https://web-platform-dx.github.io/web-features-explorer/features/scroll-into-view/) |-| [accent-color](https://web-platform-dx.github.io/web-features-explorer/features/accent-color/) | [light-dark()](https://web-platform-dx.github.io/web-features-explorer/features/light-dark/) | [Shadow parts](https://web-platform-dx.github.io/web-features-explorer/features/shadow-parts/) |-| [Active view transition](https://web-platform-dx.github.io/web-features-explorer/features/active-view-transition/) | [linear() easing](https://web-platform-dx.github.io/web-features-explorer/features/linear-easing/) | [sibling-count() and sibling-index()](https://web-platform-dx.github.io/web-features-explorer/features/sibling-count/) |-| [Anchor position container queries](https://web-platform-dx.github.io/web-features-explorer/features/container-anchor-position-queries/) | [Masks](https://web-platform-dx.github.io/web-features-explorer/features/masks/) | [Sticky positioning](https://web-platform-dx.github.io/web-features-explorer/features/sticky-positioning/) |-| [Anchor positioning](https://web-platform-dx.github.io/web-features-explorer/features/anchor-positioning/) | [overflow-clip-margin](https://web-platform-dx.github.io/web-features-explorer/features/overflow-clip-margin/) | [text-box](https://web-platform-dx.github.io/web-features-explorer/features/text-box/) |-| [calc-size()](https://web-platform-dx.github.io/web-features-explorer/features/calc-size/) | [overflow: clip](https://web-platform-dx.github.io/web-features-explorer/features/overflow-clip/) | [text-wrap: balance](https://web-platform-dx.github.io/web-features-explorer/features/text-wrap-balance/) |-| [Cascade layers](https://web-platform-dx.github.io/web-features-explorer/features/cascade-layers/) | [overlay](https://web-platform-dx.github.io/web-features-explorer/features/overlay/) | [text-wrap: pretty](https://web-platform-dx.github.io/web-features-explorer/features/text-wrap-pretty/) |-| [color-scheme](https://web-platform-dx.github.io/web-features-explorer/features/color-scheme/) | [overscroll-behavior](https://web-platform-dx.github.io/web-features-explorer/features/overscroll-behavior/) | [transition-behavior](https://web-platform-dx.github.io/web-features-explorer/features/transition-behavior/) |-| [Conic gradients](https://web-platform-dx.github.io/web-features-explorer/features/conic-gradients/) | [prefers-color-scheme media query](https://web-platform-dx.github.io/web-features-explorer/features/prefers-color-scheme/) | [Trigonometric functions (CSS)](https://web-platform-dx.github.io/web-features-explorer/features/trig-functions/) |-| [Container queries](https://web-platform-dx.github.io/web-features-explorer/features/container-queries/) | [prefers-contrast media query](https://web-platform-dx.github.io/web-features-explorer/features/prefers-contrast/) | [View transitions](https://web-platform-dx.github.io/web-features-explorer/features/view-transitions/) |-| [Container scroll-state queries](https://web-platform-dx.github.io/web-features-explorer/features/container-scroll-state-queries/) | [prefers-reduced-motion media query](https://web-platform-dx.github.io/web-features-explorer/features/prefers-reduced-motion/) | [view-transition-class](https://web-platform-dx.github.io/web-features-explorer/features/view-transition-class/) |-| [Container style queries](https://web-platform-dx.github.io/web-features-explorer/features/container-style-queries/) | [Scroll marker target pseudo-classes](https://web-platform-dx.github.io/web-features-explorer/features/scroll-marker-targets/) | [Web animations](https://web-platform-dx.github.io/web-features-explorer/features/web-animations/) |-| [content-visibility](https://web-platform-dx.github.io/web-features-explorer/features/content-visibility/) | [Scroll snap](https://web-platform-dx.github.io/web-features-explorer/features/scroll-snap/) | |-| [contrast-color()](https://web-platform-dx.github.io/web-features-explorer/features/contrast-color/) | [Scroll snap events](https://web-platform-dx.github.io/web-features-explorer/features/scroll-snap-events/) | |--### HTML & DOM (28 features)+| [::backdrop](https://web-platform-dx.github.io/web-features-explorer/features/backdrop/) | [Container style queries](https://web-platform-dx.github.io/web-features-explorer/features/container-style-queries/) | [overlay](https://web-platform-dx.github.io/web-features-explorer/features/overlay/) |+| [::file-selector-button](https://web-platform-dx.github.io/web-features-explorer/features/file-selector-button/) | [Content](https://web-platform-dx.github.io/web-features-explorer/features/content/) | [overscroll-behavior](https://web-platform-dx.github.io/web-features-explorer/features/overscroll-behavior/) |+| [::placeholder](https://web-platform-dx.github.io/web-features-explorer/features/placeholder/) | [content-visibility](https://web-platform-dx.github.io/web-features-explorer/features/content-visibility/) | [prefers-color-scheme media query](https://web-platform-dx.github.io/web-features-explorer/features/prefers-color-scheme/) |+| [::selection](https://web-platform-dx.github.io/web-features-explorer/features/selection/) | [contrast-color()](https://web-platform-dx.github.io/web-features-explorer/features/contrast-color/) | [prefers-contrast media query](https://web-platform-dx.github.io/web-features-explorer/features/prefers-contrast/) |+| [:has()](https://web-platform-dx.github.io/web-features-explorer/features/has/) | [Cross-document view transitions](https://web-platform-dx.github.io/web-features-explorer/features/cross-document-view-transitions/) | [prefers-reduced-motion media query](https://web-platform-dx.github.io/web-features-explorer/features/prefers-reduced-motion/) |+| [:host-context()](https://web-platform-dx.github.io/web-features-explorer/features/host-context/) | [currentColor](https://web-platform-dx.github.io/web-features-explorer/features/currentcolor/) | [Relative colors](https://web-platform-dx.github.io/web-features-explorer/features/relative-color/) |+| [:is()](https://web-platform-dx.github.io/web-features-explorer/features/is/) | [Custom highlights](https://web-platform-dx.github.io/web-features-explorer/features/highlight/) | [rem](https://web-platform-dx.github.io/web-features-explorer/features/rem/) |+| [:not()](https://web-platform-dx.github.io/web-features-explorer/features/not/) | [Custom properties](https://web-platform-dx.github.io/web-features-explorer/features/custom-properties/) | [resize (CSS property)](https://web-platform-dx.github.io/web-features-explorer/features/resize/) |+| [:nth-child() of <selector>](https://web-platform-dx.github.io/web-features-explorer/features/nth-child-of/) | [display animation](https://web-platform-dx.github.io/web-features-explorer/features/display-animation/) | [revert](https://web-platform-dx.github.io/web-features-explorer/features/revert-value/) |+| [:placeholder-shown](https://web-platform-dx.github.io/web-features-explorer/features/placeholder-shown/) | [em unit](https://web-platform-dx.github.io/web-features-explorer/features/em-unit/) | [Scroll marker target pseudo-classes](https://web-platform-dx.github.io/web-features-explorer/features/scroll-marker-targets/) |+| [:user-valid and :user-invalid](https://web-platform-dx.github.io/web-features-explorer/features/user-pseudos/) | [field-sizing](https://web-platform-dx.github.io/web-features-explorer/features/field-sizing/) | [Scroll snap](https://web-platform-dx.github.io/web-features-explorer/features/scroll-snap/) |+| [:where()](https://web-platform-dx.github.io/web-features-explorer/features/where/) | [filter](https://web-platform-dx.github.io/web-features-explorer/features/filter/) | [Scroll snap events](https://web-platform-dx.github.io/web-features-explorer/features/scroll-snap-events/) |+| [@function](https://web-platform-dx.github.io/web-features-explorer/features/function/) | [font-size](https://web-platform-dx.github.io/web-features-explorer/features/font-size/) | [Scroll-driven animations](https://web-platform-dx.github.io/web-features-explorer/features/scroll-driven-animations/) |+| [@scope](https://web-platform-dx.github.io/web-features-explorer/features/scope/) | [font-size-adjust](https://web-platform-dx.github.io/web-features-explorer/features/font-size-adjust/) | [scroll-initial-target](https://web-platform-dx.github.io/web-features-explorer/features/scroll-initial-target/) |+| [@starting-style](https://web-platform-dx.github.io/web-features-explorer/features/starting-style/) | [Forced colors](https://web-platform-dx.github.io/web-features-explorer/features/forced-colors/) | [scroll-target-group](https://web-platform-dx.github.io/web-features-explorer/features/scroll-target-group/) |+| [@supports](https://web-platform-dx.github.io/web-features-explorer/features/supports/) | [Gradient interpolation](https://web-platform-dx.github.io/web-features-explorer/features/gradient-interpolation/) | [scrollbar-color](https://web-platform-dx.github.io/web-features-explorer/features/scrollbar-color/) |+| [accent-color](https://web-platform-dx.github.io/web-features-explorer/features/accent-color/) | [Gradients](https://web-platform-dx.github.io/web-features-explorer/features/gradients/) | [scrollbar-width](https://web-platform-dx.github.io/web-features-explorer/features/scrollbar-width/) |+| [Active view transition](https://web-platform-dx.github.io/web-features-explorer/features/active-view-transition/) | [image-set()](https://web-platform-dx.github.io/web-features-explorer/features/image-set/) | [scrollend](https://web-platform-dx.github.io/web-features-explorer/features/scrollend/) |+| [Alt text for generated content](https://web-platform-dx.github.io/web-features-explorer/features/alt-text-generated-content/) | [Individual transform properties](https://web-platform-dx.github.io/web-features-explorer/features/individual-transforms/) | [scrollIntoView()](https://web-platform-dx.github.io/web-features-explorer/features/scroll-into-view/) |+| [Anchor position container queries](https://web-platform-dx.github.io/web-features-explorer/features/container-anchor-position-queries/) | [inherit](https://web-platform-dx.github.io/web-features-explorer/features/inherit-value/) | [Shadow parts](https://web-platform-dx.github.io/web-features-explorer/features/shadow-parts/) |+| [Anchor positioning](https://web-platform-dx.github.io/web-features-explorer/features/anchor-positioning/) | [initial](https://web-platform-dx.github.io/web-features-explorer/features/initial-value/) | [sibling-count() and sibling-index()](https://web-platform-dx.github.io/web-features-explorer/features/sibling-count/) |+| [Animations (CSS)](https://web-platform-dx.github.io/web-features-explorer/features/animations-css/) | [interpolate-size](https://web-platform-dx.github.io/web-features-explorer/features/interpolate-size/) | [Sticky positioning](https://web-platform-dx.github.io/web-features-explorer/features/sticky-positioning/) |+| [appearance](https://web-platform-dx.github.io/web-features-explorer/features/appearance/) | [isolation](https://web-platform-dx.github.io/web-features-explorer/features/isolation/) | [System colors](https://web-platform-dx.github.io/web-features-explorer/features/system-color/) |+| [aspect-ratio](https://web-platform-dx.github.io/web-features-explorer/features/aspect-ratio/) | [Lab and LCH](https://web-platform-dx.github.io/web-features-explorer/features/lab/) | [text-box](https://web-platform-dx.github.io/web-features-explorer/features/text-box/) |+| [at-rule()](https://web-platform-dx.github.io/web-features-explorer/features/supports-at-rule/) | [light-dark()](https://web-platform-dx.github.io/web-features-explorer/features/light-dark/) | [text-wrap](https://web-platform-dx.github.io/web-features-explorer/features/text-wrap/) |+| [background-blend-mode](https://web-platform-dx.github.io/web-features-explorer/features/background-blend-mode/) | [line-height](https://web-platform-dx.github.io/web-features-explorer/features/line-height/) | [text-wrap: balance](https://web-platform-dx.github.io/web-features-explorer/features/text-wrap-balance/) |+| [border-radius](https://web-platform-dx.github.io/web-features-explorer/features/border-radius/) | [linear() easing](https://web-platform-dx.github.io/web-features-explorer/features/linear-easing/) | [text-wrap: pretty](https://web-platform-dx.github.io/web-features-explorer/features/text-wrap-pretty/) |+| [box-shadow](https://web-platform-dx.github.io/web-features-explorer/features/box-shadow/) | [Logical properties](https://web-platform-dx.github.io/web-features-explorer/features/logical-properties/) | [transition-behavior](https://web-platform-dx.github.io/web-features-explorer/features/transition-behavior/) |+| [calc-size()](https://web-platform-dx.github.io/web-features-explorer/features/calc-size/) | [Masks](https://web-platform-dx.github.io/web-features-explorer/features/masks/) | [Transitions (CSS)](https://web-platform-dx.github.io/web-features-explorer/features/transitions/) |+| [Cascade layers](https://web-platform-dx.github.io/web-features-explorer/features/cascade-layers/) | [min(), max(), and clamp()](https://web-platform-dx.github.io/web-features-explorer/features/min-max-clamp/) | [Trigonometric functions (CSS)](https://web-platform-dx.github.io/web-features-explorer/features/trig-functions/) |+| [clip-path](https://web-platform-dx.github.io/web-features-explorer/features/clip-path/) | [mix-blend-mode](https://web-platform-dx.github.io/web-features-explorer/features/mix-blend-mode/) | [unset](https://web-platform-dx.github.io/web-features-explorer/features/unset-value/) |+| [color-mix()](https://web-platform-dx.github.io/web-features-explorer/features/color-mix/) | [Nesting](https://web-platform-dx.github.io/web-features-explorer/features/nesting/) | [user-select](https://web-platform-dx.github.io/web-features-explorer/features/user-select/) |+| [color-scheme](https://web-platform-dx.github.io/web-features-explorer/features/color-scheme/) | [Oklab and OkLCh](https://web-platform-dx.github.io/web-features-explorer/features/oklab/) | [View transitions](https://web-platform-dx.github.io/web-features-explorer/features/view-transitions/) |+| [Conic gradients](https://web-platform-dx.github.io/web-features-explorer/features/conic-gradients/) | [overflow-clip-margin](https://web-platform-dx.github.io/web-features-explorer/features/overflow-clip-margin/) | [view-transition-class](https://web-platform-dx.github.io/web-features-explorer/features/view-transition-class/) |+| [Container queries](https://web-platform-dx.github.io/web-features-explorer/features/container-queries/) | [overflow-wrap](https://web-platform-dx.github.io/web-features-explorer/features/overflow-wrap/) | [Viewport units](https://web-platform-dx.github.io/web-features-explorer/features/viewport-units/) |+| [Container scroll-state queries](https://web-platform-dx.github.io/web-features-explorer/features/container-scroll-state-queries/) | [overflow: clip](https://web-platform-dx.github.io/web-features-explorer/features/overflow-clip/) | [Web animations](https://web-platform-dx.github.io/web-features-explorer/features/web-animations/) |++### HTML & DOM (31 features)| | | || :--- | :--- | :--- |-| [:autofill](https://web-platform-dx.github.io/web-features-explorer/features/autofill/) | [Customizable <select>](https://web-platform-dx.github.io/web-features-explorer/features/customizable-select/) | [Interest invokers](https://web-platform-dx.github.io/web-features-explorer/features/interest-invokers/) |-| [<details>](https://web-platform-dx.github.io/web-features-explorer/features/details/) | [Declarative shadow DOM](https://web-platform-dx.github.io/web-features-explorer/features/declarative-shadow-dom/) | [Invoker commands](https://web-platform-dx.github.io/web-features-explorer/features/invoker-commands/) |+| [:autofill](https://web-platform-dx.github.io/web-features-explorer/features/autofill/) | [blocking="render"](https://web-platform-dx.github.io/web-features-explorer/features/blocking-render/) | [Interest invokers](https://web-platform-dx.github.io/web-features-explorer/features/interest-invokers/) |+| [<audio>](https://web-platform-dx.github.io/web-features-explorer/features/audio/) | [Customizable <select>](https://web-platform-dx.github.io/web-features-explorer/features/customizable-select/) | [Invoker commands](https://web-platform-dx.github.io/web-features-explorer/features/invoker-commands/) |+| [<details>](https://web-platform-dx.github.io/web-features-explorer/features/details/) | [Declarative shadow DOM](https://web-platform-dx.github.io/web-features-explorer/features/declarative-shadow-dom/) | [Lazy-loading media](https://web-platform-dx.github.io/web-features-explorer/features/loading-lazy-media/) || [<dialog closedby>](https://web-platform-dx.github.io/web-features-explorer/features/dialog-closedby/) | [Email, telephone, and URL <input> types](https://web-platform-dx.github.io/web-features-explorer/features/input-email-tel-url/) | [moveBefore()](https://web-platform-dx.github.io/web-features-explorer/features/move-before/) || [<dialog>](https://web-platform-dx.github.io/web-features-explorer/features/dialog/) | [Fetch priority](https://web-platform-dx.github.io/web-features-explorer/features/fetch-priority/) | [MutationObserver](https://web-platform-dx.github.io/web-features-explorer/features/mutationobserver/) || [<link rel="expect">](https://web-platform-dx.github.io/web-features-explorer/features/link-rel-expect/) | [Form-associated custom elements](https://web-platform-dx.github.io/web-features-explorer/features/form-associated-custom-elements/) | [Mutually exclusive <details> elements](https://web-platform-dx.github.io/web-features-explorer/features/details-name/) || [<link rel="preload">](https://web-platform-dx.github.io/web-features-explorer/features/link-rel-preload/) | [hidden="until-found"](https://web-platform-dx.github.io/web-features-explorer/features/hidden-until-found/) | [Popover](https://web-platform-dx.github.io/web-features-explorer/features/popover/) || [<progress>](https://web-platform-dx.github.io/web-features-explorer/features/progress/) | [HTML in canvas](https://web-platform-dx.github.io/web-features-explorer/features/canvas-html/) | [popover="hint"](https://web-platform-dx.github.io/web-features-explorer/features/popover-hint/) || [<slot>](https://web-platform-dx.github.io/web-features-explorer/features/slot/) | [HTML setter methods](https://web-platform-dx.github.io/web-features-explorer/features/html-setters/) | [Shadow DOM](https://web-platform-dx.github.io/web-features-explorer/features/shadow-dom/) |-| [Autonomous custom elements](https://web-platform-dx.github.io/web-features-explorer/features/autonomous-custom-elements/) | [HTML streaming setters](https://web-platform-dx.github.io/web-features-explorer/features/html-streaming-setters/) | |-| [blocking="render"](https://web-platform-dx.github.io/web-features-explorer/features/blocking-render/) | [inert](https://web-platform-dx.github.io/web-features-explorer/features/inert/) | |+| [<video>](https://web-platform-dx.github.io/web-features-explorer/features/video/) | [HTML streaming setters](https://web-platform-dx.github.io/web-features-explorer/features/html-streaming-setters/) | |+| [Autonomous custom elements](https://web-platform-dx.github.io/web-features-explorer/features/autonomous-custom-elements/) | [inert](https://web-platform-dx.github.io/web-features-explorer/features/inert/) | |-### JavaScript & APIs (44 features)+### JavaScript & APIs (51 features)| | | || :--- | :--- | :--- |-| [<template for>](https://web-platform-dx.github.io/web-features-explorer/features/template-for/) | [Keyboard events](https://web-platform-dx.github.io/web-features-explorer/features/keyboard-events/) | [Speculation rules](https://web-platform-dx.github.io/web-features-explorer/features/speculation-rules/) |-| [AbortController and AbortSignal](https://web-platform-dx.github.io/web-features-explorer/features/aborting/) | [Language detector](https://web-platform-dx.github.io/web-features-explorer/features/languagedetector/) | [Subresource integrity](https://web-platform-dx.github.io/web-features-explorer/features/subresource-integrity/) |-| [ARIA attribute reflection](https://web-platform-dx.github.io/web-features-explorer/features/aria-attribute-reflection/) | [LanguageModel](https://web-platform-dx.github.io/web-features-explorer/features/languagemodel/) | [Summarizer](https://web-platform-dx.github.io/web-features-explorer/features/summarizer/) |-| [cross-origin-storage](https://web-platform-dx.github.io/web-features-explorer/features/tmp-cross-origin-storage/) | [Lazy-loading images and iframes](https://web-platform-dx.github.io/web-features-explorer/features/loading-lazy/) | [SVG](https://web-platform-dx.github.io/web-features-explorer/features/svg/) |-| [document.modelContext](https://web-platform-dx.github.io/web-features-explorer/features/document-modelcontext/) | [Local network access](https://web-platform-dx.github.io/web-features-explorer/features/local-network-access/) | [Temporal](https://web-platform-dx.github.io/web-features-explorer/features/temporal/) |-| [enterkeyhint](https://web-platform-dx.github.io/web-features-explorer/features/enterkeyhint/) | [Long animation frames performance entries](https://web-platform-dx.github.io/web-features-explorer/features/long-animation-frames/) | [Top-level await](https://web-platform-dx.github.io/web-features-explorer/features/top-level-await/) |-| [Event timing performance entries](https://web-platform-dx.github.io/web-features-explorer/features/event-timing/) | [Navigation API](https://web-platform-dx.github.io/web-features-explorer/features/navigation/) | [Translator](https://web-platform-dx.github.io/web-features-explorer/features/translator/) |-| [Federated credential management](https://web-platform-dx.github.io/web-features-explorer/features/fedcm/) | [Page visibility](https://web-platform-dx.github.io/web-features-explorer/features/page-visibility/) | [Trusted types](https://web-platform-dx.github.io/web-features-explorer/features/trusted-types/) |-| [Fetch](https://web-platform-dx.github.io/web-features-explorer/features/fetch/) | [Page visibility state performance entries](https://web-platform-dx.github.io/web-features-explorer/features/page-visibility-state/) | [User agent client hints](https://web-platform-dx.github.io/web-features-explorer/features/ua-client-hints/) |-| [fetchLater](https://web-platform-dx.github.io/web-features-explorer/features/fetchlater/) | [Partitioned cookies](https://web-platform-dx.github.io/web-features-explorer/features/partitioned-cookies/) | [Web app origin migration](https://web-platform-dx.github.io/web-features-explorer/features/app-migration/) |-| [Form-associated WebMCP attributes](https://web-platform-dx.github.io/web-features-explorer/features/declarative-webmcp/) | [Permissions policy](https://web-platform-dx.github.io/web-features-explorer/features/permissions-policy/) | [Web authentication](https://web-platform-dx.github.io/web-features-explorer/features/webauthn/) |-| [HTML processing instructions](https://web-platform-dx.github.io/web-features-explorer/features/html-processing-instructions/) | [Registered custom properties](https://web-platform-dx.github.io/web-features-explorer/features/registered-custom-properties/) | [Web authentication signal methods](https://web-platform-dx.github.io/web-features-explorer/features/webauthn-signals/) |-| [inputmode](https://web-platform-dx.github.io/web-features-explorer/features/inputmode/) | [Resize observer](https://web-platform-dx.github.io/web-features-explorer/features/resize-observer/) | [Web Cryptography](https://web-platform-dx.github.io/web-features-explorer/features/web-cryptography/) |-| [Intersection observer](https://web-platform-dx.github.io/web-features-explorer/features/intersection-observer/) | [Sanitizer API](https://web-platform-dx.github.io/web-features-explorer/features/sanitizer/) | [WebAssembly](https://web-platform-dx.github.io/web-features-explorer/features/wasm/) |-| [Intl.DurationFormat](https://web-platform-dx.github.io/web-features-explorer/features/intl-duration-format/) | [Scheduler API](https://web-platform-dx.github.io/web-features-explorer/features/scheduler/) | |+| [<meta name="text-scale">](https://web-platform-dx.github.io/web-features-explorer/features/meta-text-scale/) | [Intersection observer](https://web-platform-dx.github.io/web-features-explorer/features/intersection-observer/) | [Scheduler API](https://web-platform-dx.github.io/web-features-explorer/features/scheduler/) |+| [<template for>](https://web-platform-dx.github.io/web-features-explorer/features/template-for/) | [Intl.DurationFormat](https://web-platform-dx.github.io/web-features-explorer/features/intl-duration-format/) | [Small, large, and dynamic viewport units](https://web-platform-dx.github.io/web-features-explorer/features/viewport-unit-variants/) |+| [AbortController and AbortSignal](https://web-platform-dx.github.io/web-features-explorer/features/aborting/) | [Keyboard events](https://web-platform-dx.github.io/web-features-explorer/features/keyboard-events/) | [Soft navigation performance entries](https://web-platform-dx.github.io/web-features-explorer/features/soft-navigations/) |+| [ARIA attribute reflection](https://web-platform-dx.github.io/web-features-explorer/features/aria-attribute-reflection/) | [Language detector](https://web-platform-dx.github.io/web-features-explorer/features/languagedetector/) | [Speculation rules](https://web-platform-dx.github.io/web-features-explorer/features/speculation-rules/) |+| [autocorrect](https://web-platform-dx.github.io/web-features-explorer/features/autocorrect/) | [LanguageModel](https://web-platform-dx.github.io/web-features-explorer/features/languagemodel/) | [Summarizer](https://web-platform-dx.github.io/web-features-explorer/features/summarizer/) |+| [corner-shape](https://web-platform-dx.github.io/web-features-explorer/features/corner-shape/) | [Lazy-loading images and iframes](https://web-platform-dx.github.io/web-features-explorer/features/loading-lazy/) | [SVG](https://web-platform-dx.github.io/web-features-explorer/features/svg/) |+| [document.modelContext](https://web-platform-dx.github.io/web-features-explorer/features/document-modelcontext/) | [light-dark() image values](https://web-platform-dx.github.io/web-features-explorer/features/light-dark-image/) | [Temporal](https://web-platform-dx.github.io/web-features-explorer/features/temporal/) |+| [enterkeyhint](https://web-platform-dx.github.io/web-features-explorer/features/enterkeyhint/) | [Local network access](https://web-platform-dx.github.io/web-features-explorer/features/local-network-access/) | [text-fit](https://web-platform-dx.github.io/web-features-explorer/features/text-fit/) |+| [Event timing performance entries](https://web-platform-dx.github.io/web-features-explorer/features/event-timing/) | [Long animation frames performance entries](https://web-platform-dx.github.io/web-features-explorer/features/long-animation-frames/) | [Top-level await](https://web-platform-dx.github.io/web-features-explorer/features/top-level-await/) |+| [Federated credential management](https://web-platform-dx.github.io/web-features-explorer/features/fedcm/) | [Navigation API](https://web-platform-dx.github.io/web-features-explorer/features/navigation/) | [Translator](https://web-platform-dx.github.io/web-features-explorer/features/translator/) |+| [Fetch](https://web-platform-dx.github.io/web-features-explorer/features/fetch/) | [Page visibility](https://web-platform-dx.github.io/web-features-explorer/features/page-visibility/) | [Trusted types](https://web-platform-dx.github.io/web-features-explorer/features/trusted-types/) |+| [fetchLater](https://web-platform-dx.github.io/web-features-explorer/features/fetchlater/) | [Page visibility state performance entries](https://web-platform-dx.github.io/web-features-explorer/features/page-visibility-state/) | [User agent client hints](https://web-platform-dx.github.io/web-features-explorer/features/ua-client-hints/) |+| [Form-associated WebMCP attributes](https://web-platform-dx.github.io/web-features-explorer/features/declarative-webmcp/) | [Partitioned cookies](https://web-platform-dx.github.io/web-features-explorer/features/partitioned-cookies/) | [Web app origin migration](https://web-platform-dx.github.io/web-features-explorer/features/app-migration/) |+| [HTML processing instructions](https://web-platform-dx.github.io/web-features-explorer/features/html-processing-instructions/) | [Permissions policy](https://web-platform-dx.github.io/web-features-explorer/features/permissions-policy/) | [Web authentication](https://web-platform-dx.github.io/web-features-explorer/features/webauthn/) |+| [image()](https://web-platform-dx.github.io/web-features-explorer/features/image-function/) | [Registered custom properties](https://web-platform-dx.github.io/web-features-explorer/features/registered-custom-properties/) | [Web authentication signal methods](https://web-platform-dx.github.io/web-features-explorer/features/webauthn-signals/) |+| [inputmode](https://web-platform-dx.github.io/web-features-explorer/features/inputmode/) | [Resize observer](https://web-platform-dx.github.io/web-features-explorer/features/resize-observer/) | [WebAssembly](https://web-platform-dx.github.io/web-features-explorer/features/wasm/) |+| [Interaction contentful paint performance entries](https://web-platform-dx.github.io/web-features-explorer/features/interaction-contentful-paint/) | [Sanitizer API](https://web-platform-dx.github.io/web-features-explorer/features/sanitizer/) | [WebOTP](https://web-platform-dx.github.io/web-features-explorer/features/web-otp/) |</details><details>-<summary><strong>153 real-world developer use cases</strong></summary>+<summary><strong>166 real-world developer use cases</strong></summary><h3>accessibility</h3>- **[accessible-error-announcement](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/accessibility/accessible-error-announcement.md)**: Synchronize programmatic accessibility states (like aria-invalid) with the visual :user-invalid state to ensure screen reader users receive error feedback only after interaction, mirroring the visual experience.+- **[accessible-generated-content](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/accessibility/accessible-generated-content.md)**: Use CSS generated content (`::before`/`::after`) in ways that stay accessible, including alternative text for decorative content.+- **[respect-os-text-scale](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/accessibility/respect-os-text-scale.md)**: Respect the operating system's text scale preference for a page so font sizes, layout, and rem-based measurements follow the user's accessibility settings.<h3>built-in-ai</h3>@@ -166,15 +187,19 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro<h3>css</h3>- **[animate-to-intrinsic-sizes](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/animate-to-intrinsic-sizes.md)**: Smoothly animate interactive components (like accordions, menus, and expanding cards) to and from their natural dimensions.+- **[atrule-support-conditionals](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/atrule-support-conditionals.md)**: Conditionally apply certain CSS rules or declarations only if a certain at-rule is supported by the browser.- **[calculate-with-intrinsic-sizes](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/calculate-with-intrinsic-sizes.md)**: Calculate the size of an element based on its intrinsic size, while ensuring it fits within given design constraints.- **[child-state-based-styling](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/child-state-based-styling.md)**: Build a component that changes its styling based on the state of one of its child elements. For example, a component that renders in light or dark mode based on whether a theme toggle is checked (or not).- **[content-based-styling](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/content-based-styling.md)**: Build a component that changes its layout based on whether it contains specific child elements (or not). For example, if the component contains an image, use a multi-column layout, otherwise default to a single-column layout.+- **[css](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/css.md)**: Action-oriented guidelines for modern CSS architecture, including the cascade, selectors, scoping, nesting, and design tokens. Use this guide when authoring styles or managing design systems.- **[design-token-reactivity](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/design-token-reactivity.md)**: Define higher-order design tokens, like density modes (compact, comfortable, spacious) or themes and have descendant components react to changes directly and in component-appropriate ways.- **[dynamic-sibling-styling](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/dynamic-sibling-styling.md)**: Create dynamic visual spectrums or layout arrangements that automatically adapt to the number of elements in a group.- **[fluid-scaling](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/fluid-scaling.md)**: Scale items like font size, spacing, and media sizes smoothly based on the parent container's size rather than using fixed breakpoints- **[individual-transform-properties](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/individual-transform-properties.md)**: Animate or override individual CSS transform properties (e.g. translate, rotate, scale) independently of other transform properties on a single element.- **[overflow-clipping-control](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/overflow-clipping-control.md)**: Adjust the visible clipping boundary of an element to align with the content edge, padding edge, or border edge—or a specified offset from any of these—offering finer-grained control over how content is clipped.- **[reduce-style-repetition](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/reduce-style-repetition.md)**: Reduce excessive style repetition by encapsulating complex or dynamic styling logic into reusable functions (such as a function that computes a gradient based on a set of input parameters).+- **[responsive-design](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/responsive-design.md)**: Build UI that adapts to container and viewport size, including container queries, dynamic viewport units, aspect ratios, and responsive typography.+- **[selector-atrule-combinations](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/selector-atrule-combinations.md)**: Target elements based on the intersection or union of selectors and conditional @-rules while minimizing repetition.- **[size-aware-styling](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/size-aware-styling.md)**: Build a component whose styles can be conditionally dependent on its own width or height, rather than the width or height of the viewport. For example a card component that can change its layouts depending on how large it is, or a call-to-action button that can conditionally display helper text based on its width.- **[style-parent-with-has](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/style-parent-with-has.md)**: Style parent elements of a form field (e.g. labels or fieldsets) when the field is invalid.- **[usage-aware-component-variations](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/usage-aware-component-variations.md)**: Build components that adapt visual logic based on semantic context using CSS container style queries.@@ -195,6 +220,7 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro- **[required-field-feedback](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/forms/required-field-feedback.md)**: Provide error message for required form fields that were skipped or left empty *only* after user interaction, to avoid preemptive errors and ensure feedback is timely and contextually relevant to the user's flow.- **[rich-media-picker](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/forms/rich-media-picker.md)**: Create a custom select component whose options can contain complex HTML formatting (e.g. images, icons, and other rich formatting) rather than just plain text.- **[select-menu-interaction](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/forms/select-menu-interaction.md)**: Validate that a non-default option has been chosen in a select menu only after the user has interacted with the control.+- **[sms-otp-form](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/forms/sms-otp-form.md)**: Verify user phone numbers and one-time passcodes delivered over SMS with automatic code extraction and accessible form input.- **[validate-input-after-interaction](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/forms/validate-input-after-interaction.md)**: Show form field validation feedback (e.g. password complexity or email format requirements) only after the user has finished their initial interaction, avoiding premature errors on page load or while the user is typing.<h3>html</h3>@@ -220,7 +246,6 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro<h3>performance</h3>-- **[avoid-redundant-large-asset-downloads](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/avoid-redundant-large-asset-downloads.md)**: Avoid re-downloading and re-storing large shared assets, such as AI models, Wasm modules, or fully-bundled JavaScript libraries, that a visitor's browser may already hold from an unrelated site.- **[batch-analytics-events](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/batch-analytics-events.md)**: Debounce and batch multiple analytics events together in a single beacon to minimize network contention and reduce server load, while still delivering real-time updates.- **[break-up-long-tasks](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/break-up-long-tasks.md)**: Break up heavy synchronous processing (complex computations and/or long loops) or DOM updates, to let the browser handle user input and repaint the screen.- **[calculate-total-foreground-time](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/calculate-total-foreground-time.md)**: Calculate the total time a user actually spent viewing a page, excluding periods when the tab was in the background.@@ -237,8 +262,9 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro- **[identify-heavy-scripts](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/identify-heavy-scripts.md)**: Identify the scripts most responsible for long animation frames- **[identify-inp-causes](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/identify-inp-causes.md)**: Identify slow running JavaScript that is impacting INP metric- **[improve-next-page-load-performance](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/improve-next-page-load-performance.md)**: Improve page load performance by prefetching or prerendering pages that the user is likely to visit next.+- **[interaction-paint-timing](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/interaction-paint-timing.md)**: Measure the time it takes for user interactions and client-side navigations to render new contentful updates on screen.- **[interactions-in-complex-layouts](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/interactions-in-complex-layouts.md)**: Make interactions snappier and more responsive (reducing Interaction to Next Paint (INP) scores) by avoiding layout re-calculations in complex layouts, such as data-heavy dashboards or spreadsheet-style grids.-- **[load-shared-resources-declaratively](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/load-shared-resources-declaratively.md)**: Serve popular, unmodified scripts, stylesheets, and JavaScript modules from a shared cross-origin cache using markup or import syntax alone, without writing custom caching logic.+- **[lazy-load-video-and-audio](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/lazy-load-video-and-audio.md)**: Defer downloading offscreen video and audio assets, including video poster images and preloaded media data, until the media player approaches the viewport to conserve bandwidth and reduce network contention during initial page load.- **[optimize-image-priority](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/optimize-image-priority.md)**: Optimize the loading priority of Largest Contentful Paint (LCP) candidate images and deprioritize non-critical images to reduce critical resource load delays.- **[optimize-preload-priority](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/optimize-preload-priority.md)**: Optimize the relative priority of preloaded content to reduce critical resource load delays.- **[optimize-script-priority](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/optimize-script-priority.md)**: Optimize the loading priority of scripts by boosting critical asynchronous scripts and deprioritizing non-essential or late-body scripts to improve sequencing and reduce delays.@@ -246,7 +272,6 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro- **[resolution-optimized-pseudo-elements](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/resolution-optimized-pseudo-elements.md)**: Use resolution-optimized images in CSS pseudo-elements (such as `::before` and `::after`) to reduce the number of DOM nodes.- **[schedule-tasks-by-priority](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/schedule-tasks-by-priority.md)**: Schedule tasks with different priorities to ensure critical work runs first while background work is deferred.- **[sequence-distributed-events](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/sequence-distributed-events.md)**: Log and sequence operations in distributed microservices or high-throughput tracing environments by recording timestamps with nanosecond resolution.-- **[share-web-fonts-across-origins](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/performance/share-web-fonts-across-origins.md)**: Serve large, popular web fonts from a shared cross-origin cache instead of re-downloading them from a font CDN on every site that references them.<h3>privacy</h3>@@ -300,6 +325,7 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro- **[interest-triggered-action-previews](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/interest-triggered-action-previews.md)**: Show a live preview of a button's effect when a user signals interest (e.g. hovering, focusing, or long-pressing) but before they commit to clicking.- **[interest-triggered-tooltips](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/interest-triggered-tooltips.md)**: Show a tooltip or supplemental information when a user hovers over, focuses on, or long-presses an interactive element, without requiring a click.- **[light-dismiss-a-dialog](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/light-dismiss-a-dialog.md)**: Create a modal dialog that can be closed via light dismiss (i.e. clicking or tapping outside of the dialog)+- **[motion](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/motion.md)**: Animate UI with CSS transitions, animations, scroll-driven animations, and view transitions while keeping motion on the compositor and respecting reduced-motion preferences.- **[move-dom-element-without-losing-state](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/move-dom-element-without-losing-state.md)**: Move or reparent a DOM element without losing important element state, such as interactivity states (:focus/:active), `<iframe>` loading state, animation/transition state, etc- **[parallax-scroll-effects](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/parallax-scroll-effects.md)**: Create scroll-based effects (such as parallax) where foreground and background layers move at different rates, creating a sense of depth as the user scrolls.- **[persistent-top-layer-ui](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/persistent-top-layer-ui.md)**: Keep a modal dialog, fullscreen element, or native popover visibly open and functionally active when its underlying DOM node is moved or reparented in the DOM.@@ -317,6 +343,7 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro<h3>ui-components</h3>+- **[dark-mode-toggle](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-components/dark-mode-toggle.md)**: Build a dark mode toggle component that allows users to override their system color scheme preference for the current site.- **[navigation-drawer](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-components/navigation-drawer.md)**: Create a navigation drawer component that, when triggered from a menu button, slides in from the side overlayed on top of existing page content, and slides out when dismissed (by swiping away, tapping outside, or pressing escape).- **[persistent-app-tours](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-components/persistent-app-tours.md)**: Create persistent onboarding walkthroughs using tethered native overlays that stay open during user interaction.- **[persistent-toast-notifications](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-components/persistent-toast-notifications.md)**: Create non-intrusive toast and overlay notifications for persistent, stackable messaging and state communication.@@ -329,10 +356,13 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro- **[adapt-scrollbar-to-contrast-preferences](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/adapt-scrollbar-to-contrast-preferences.md)**: Enhance scrollbar visibility for users who prefer high-contrast interfaces- **[apply-webgl-shaders](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/apply-webgl-shaders.md)**: Apply custom visual effects with WebGL shaders to HTML content.+- **[browser-ui-theming](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/browser-ui-theming.md)**: Theme browser-generated UI such as text selection, scrollbars, form controls, and pickers with CSS instead of re-creating it with custom elements.+- **[color](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/color.md)**: Color guidance for the web, including contrast requirements, light and dark color schemes, Forced Colors Mode, and generating tints and shades from a base color.- **[complex-shapes](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/complex-shapes.md)**: Clip elements and their content to any free-form shape, like a symbol, brush stroke, or organic texture for more expressive designs.- **[contrast-color](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/contrast-color.md)**: Select a readable text color with sufficient contrast on a dynamic background color.- **[customize-scrollbar-color-and-thickness](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/customize-scrollbar-color-and-thickness.md)**: Customize the color or thickness of a scrollbar- **[dark-mode](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/dark-mode.md)**: Implement dark mode support in a way that respects the user's light/dark theme preference and adapts browser UI (e.g. scrollbars, form controls, etc)+- **[equal-width-text-lines](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/equal-width-text-lines.md)**: Make every line of a multi-line heading or lockup span the same width, as in poster-style or stacked-headline typography. Unlike justified text, the text itself is sized to the width rather than the spacing stretched- **[export-html-media-from-canvas](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/export-html-media-from-canvas.md)**: Capture and export dynamic HTML content as images or video frames from within canvas.- **[expose-canvas-content-to-browser-features](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/expose-canvas-content-to-browser-features.md)**: Expose content rendered in a canvas to browser features like assistive technologies, translation, or reading mode.- **[improve-text-layout-and-legibility](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/improve-text-layout-and-legibility.md)**: Improve the layout and legibility of short standalone text content, such as headings no longer than a few lines, by enabling the browser to apply evenly balanced line breaks when wrapping text.@@ -340,6 +370,8 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro- **[precise-text-alignment](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/precise-text-alignment.md)**: Achieve precise vertical alignment with text of any font. For example, exactly equal visual padding above and below text, or aligning text perfectly flush with adjacent icons or images.- **[shaped-cutouts](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/shaped-cutouts.md)**: Combine multiple shapes to create complex cutouts or 'knockout' effects in elements, such as adding a notch to an element.- **[soft-edge-content-fade](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/soft-edge-content-fade.md)**: Apply a transparency gradient to content edges to indicate further scrollable areas or to obscure payment-walled text.+- **[typography](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/typography.md)**: Typography best practices for the web, including font sizing units, line height, text wrapping and balancing, and fluid type that scales with the viewport.+- **[visual-effects](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/visual-effects.md)**: Visual effects with CSS such as layered shadows, blend modes, gradients with predictable color interpolation, and patterns like stripes, checkerboards, dots, and pie charts built from gradients alone.- **[visually-stable-font-fallbacks](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/visually-stable-font-fallbacks.md)**: Define font styles such that text remains readable and visually consistent in the event that there's a swap between the perferred font and one of the fallbacks (or vise versa).- **[visually-stable-mixed-fonts](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/visually-stable-mixed-fonts.md)**: Define font styles such that text remains readable and visually consistent in situations where multiple fonts are used to render a single block of text.- **[visually-texture-content](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/visually-texture-content.md)**: Apply realistic weathering and texture patterns to elements to give them an organic, aged, or physical material appearance.@@ -479,10 +511,10 @@ We developed a robust eval harness to ensure that the content is **empirically p| :--- | :--- | :---: | :---: || Sep 11 | codex_cli (gpt-5.6-sol) | 132 / 1124 | 59% → 81% (**+22pp**) || Sep 11 | claude_code (sonnet-5) | 132 / 1124 | 54% → 87% (**+33pp**) |-| Sep 11 | antigravity (gemini-3.8-flash-medium) | 132 / 1124 | 65% → 91% (**+26pp**) |+| Sep 11 | antigravity_cli (gemini-3.8-flash-medium) | 132 / 1124 | 65% → 91% (**+26pp**) || Sep 9 | codex_cli (gpt-5.6-sol) | 132 / 1045 | 61% → 83% (**+22pp**) || Sep 9 | claude_code (sonnet-5) | 132 / 1124 | 53% → 85% (**+32pp**) |-| Sep 9 | antigravity (gemini-3.8-flash-medium) | 132 / 1124 | 69% → 92% (**+23pp**) |+| Sep 9 | antigravity_cli (gemini-3.8-flash-medium) | 132 / 1124 | 69% → 92% (**+23pp**) || Sep 7 | codex_cli (gpt-5.6-sol) | 132 / 1124 | 61% → 82% (**+21pp**) || Sep 7 | claude_code (sonnet-5) | 132 / 1124 | 54% → 86% (**+32pp**) || Sep 4 | codex_cli (gpt-5.6-sol) | 132 / 1092 | 59% → 80% (**+21pp**) |@@ -503,7 +535,7 @@ npx modern-web-guidance@latest install --choose## <img src="https://github.com/GoogleChrome/modern-web-guidance/raw/main/.github/img/lock.svg" width="24" height="24" style="vertical-align: middle; margin-right: 4px;"> Telemetry & Privacy-Google collects anonymous usage information to improve the tool's reliability, relevance, and performance. Collected information includes installation counts, guide retrieval IDs, and CLI tool search queries generated by the agent (e.g. "dark mode scrollbar color-scheme"). Raw user prompts are not collected. You can inspect what is collected in [modern-web.ts](https://github.com/GoogleChrome/modern-web-guidance-src/blob/main/serving/bin/modern-web.ts).+Google collects anonymous usage information to improve the tool's reliability, relevance, and performance. Collected information includes installation counts, the calling agent name, guide retrieval IDs, and CLI tool search queries generated by the agent (e.g. "dark mode scrollbar color-scheme"). Raw user prompts are not collected. You can inspect what is collected in [modern-web.ts](https://github.com/GoogleChrome/modern-web-guidance-src/blob/main/serving/bin/modern-web.ts).> [!TIP]> **To Opt-Out:** set the `DISABLE_TELEMETRY=1` env variable in your shell profile (e.g., `.bashrc` or `.zshrc`):diff --git a/gemini-extension.json b/gemini-extension.jsonindex 6291184..d607fb9 100644--- a/gemini-extension.json+++ b/gemini-extension.json@@ -1,7 +1,7 @@{"name": "modern-web-guidance","description": "Keep your coding agent up to date with the latest web best practices",- "version": "0.0.191",+ "version": "0.0.192","author": {"name": "Google Chrome"}diff --git a/kimi.plugin.json b/kimi.plugin.jsonindex 5b00024..75eb59d 100644--- a/kimi.plugin.json+++ b/kimi.plugin.json@@ -1,7 +1,7 @@{"name": "modern-web-guidance","description": "Modern Web Guidance is an agent skill and CLI tool designed to help AI coding agents build web applications using modern, secure, and high-performance APIs rather than outdated workarounds. Supported by the Google Chrome team, it injects expert-curated web platform best practices directly into an agent's context window to prevent the generation of bloated, legacy code.",- "version": "0.0.191",+ "version": "0.0.192","author": {"name": "Google Chrome"},diff --git a/package.json b/package.jsonindex 8cce923..07a32d5 100644--- a/package.json+++ b/package.json@@ -3,7 +3,7 @@"displayName": "Modern Web Guidance","description": "Keep your agent up to date on the latest web best practices.","license": "Apache-2.0",- "version": "0.0.191",+ "version": "0.0.192","publisher": "GoogleChrome","repository": {"url": "https://github.com/GoogleChrome/modern-web-guidance-src"diff --git a/skills/modern-web-guidance/guides/accessibility/accessibility.md b/skills/modern-web-guidance/guides/accessibility/accessibility.mdindex ed2e168..603dfa8 100644--- a/skills/modern-web-guidance/guides/accessibility/accessibility.md+++ b/skills/modern-web-guidance/guides/accessibility/accessibility.md@@ -7,25 +7,84 @@ Keep these principles in mind throughout:- **Accessibility is the minimum, not the ceiling.** Conformance to standards is the floor; aim for genuine usability.- **Patterns are use-case specific.** No checklist replaces real testing — including testing with disabled users — to confirm a given implementation is actually accessible in context.+Contents:++- [1. Content Navigability and Structure](#1-content-navigability-and-structure)+ - [Landmarks](#landmarks)+ - [Headings](#headings)+ - [Lists and tables](#lists-and-tables)+ - [Skip links](#skip-links)+- [2. Semantic HTML and ARIA](#2-semantic-html-and-aria)+ - [Prefer native HTML](#prefer-native-html)+ - [ARIA roles and states](#aria-roles-and-states)+- [3. Accessible Names and Descriptions](#3-accessible-names-and-descriptions)+ - [Naming mechanisms](#naming-mechanisms)+ - [Choosing the name](#choosing-the-name)+ - [Descriptions](#descriptions)+ - [Code Example: Visually Hidden Utility](#code-example-visually-hidden-utility)+- [4. Document Metadata and Language](#4-document-metadata-and-language)+ - [Language](#language)+ - [Titles](#titles)+ - [Iframes](#iframes)+- [5. Keyboard and Focus Management](#5-keyboard-and-focus-management)+ - [Tab order and focusability](#tab-order-and-focusability)+ - [Keyboard handlers](#keyboard-handlers)+ - [Focus indicators](#focus-indicators)+ - [Touch targets](#touch-targets)+- [6. Alternate Text and Media](#6-alternate-text-and-media)+ - [Images](#images)+ - [Inline SVGs](#inline-svgs)+ - [Complex images and charts](#complex-images-and-charts)+ - [Audio and video](#audio-and-video)+ - [CSS generated content](#css-generated-content)+ - [Content Visibility Decision Matrix](#content-visibility-decision-matrix)+- [7. Forms and Input Controls](#7-forms-and-input-controls)+ - [Labels and hints](#labels-and-hints)+ - [Input assistance and validation](#input-assistance-and-validation)+- [8. Live Regions](#8-live-regions)+ - [Live Region Urgency Table](#live-region-urgency-table)+ - [When to announce](#when-to-announce)+ - [Managing announcements](#managing-announcements)+- [9. Color](#9-color)+- [10. Typography](#10-typography)+- [11. Motion and Preferences](#11-motion-and-preferences)+- [12. Modals and Native Dialogs](#12-modals-and-native-dialogs)+ - [Native `<dialog>`](#native-dialog)+ - [Custom overlays](#custom-overlays)+- [13. Testing Validations](#13-testing-validations)+ - [Automated checks](#automated-checks)+ - [Manual testing](#manual-testing)++## 1. Content Navigability and Structure-### Actionable Guidelines+### Landmarks-#### DOs- **Place all content within landmarks**: Wrap each relevant part of the page in `<header>`, `<nav>`, `<main>`, `<aside>`, and `<footer>` elements so assistive-tech users can jump between regions.-- **Structure main content with headings**: Use `<h1>`–`<h6>` sequentially (no jumping `<h1>` → `<h4>`) so screen-reader users get a navigable outline.-- **Use lists for repeated, contiguous content**: `<ul>`/`<ol>` give assistive tech a count up front and let users skip the entire group.-- **Provide skip links** prior to repeated content like site headers with navigation or long/infinite lists, so that keyboard users can easily bypass them. Make sure the target is focusable (e.g. `<main id="content" tabindex="-1">`).-- **Semantic Tables**: Use `<caption>` and `<th scope="col">` (or `<th scope="row">`) for data tables.+- **Don't overuse landmarks**: Too many landmarks dilute their value. In particular, avoid labeling a `<section>` (which turns it into a `region` landmark) — `region` should be a last resort when no other landmark fits.++### Headings-#### DON'Ts+- **Structure main content with headings**: Use `<h1>`–`<h6>` sequentially (no jumping `<h1>` → `<h4>`) so screen-reader users get a navigable outline.- **Don't use fake headings**: Never style `<div>` or `<span>` to look like headings without standard `<h1>`–`<h6>` tags.- **Don't place headings inside `<summary>`, and avoid relying on headings inside `<details>` content**: Headings inside `<summary>` may be hidden from screen-reader heading lists and heading-navigation shortcuts entirely; headings inside `<details>` content are only reachable via heading navigation when the disclosure is open.- **Caveat**: If a heading must act as a disclosure trigger, use a more robust alternative to `<details>`/`<summary>` instead, e.g. an accordion or a disclosure implemented with ARIA where the heading wraps the button.++### Lists and tables++- **Use lists for repeated, contiguous content**: `<ul>`/`<ol>` give assistive tech a count up front and let users skip the entire group.+- **Semantic Tables**: Use `<caption>` and `<th scope="col">` (or `<th scope="row">`) for data tables.- **Don't use tables for layout**: Use CSS Grid/Flexbox for visual layouts.-- **Don't overuse landmarks**: Too many landmarks dilute their value. In particular, avoid labeling a `<section>` (which turns it into a `region` landmark) — `region` should be a last resort when no other landmark fits.-### Code Examples+### Skip links++- **Provide skip links** prior to repeated content like site headers with navigation or long/infinite lists, so that keyboard users can easily bypass them. Make sure the target is focusable (e.g. `<main id="content" tabindex="-1">`).++```html+<!-- Good: Skip to main content -->+<a href="#content" class="skip-link">Skip to main content</a>+<main id="content" tabindex="-1">...</main>+``````html<!-- Good: Semantic landmarks, heading hierarchy, skip link -->@@ -58,40 +117,45 @@ Keep these principles in mind throughout:## 2. Semantic HTML and ARIA-### Actionable Guidelines+### Prefer native HTML-#### DOs- **Prefer HTML elements and attributes to ARIA**: A native element comes with the right role and behavior. `<button>` already implies `role="button"`; `required` already implies `aria-required`.-- **Match ARIA implementations to actual behavior**: If you set `role="tab"`, the element must behave like a tab — including keyboard interactions. Many ARIA patterns can't be implemented in CSS alone and need JavaScript.-- **Be deliberate about `disabled` vs `aria-disabled`**: `disabled` removes the element from the focus order entirely (and `tabindex="0"` won't bring it back), which is often wrong for toolbar buttons or links. `aria-disabled="true"` keeps the element focusable so users can land on it and learn it's disabled.--#### DON'Ts- **Don't use ARIA when native HTML exists**: Avoid `<div role="button">` or `<a role="button">` if `<button>` works.- **Don't add redundant ARIA roles or properties**: Avoid `<ul role="list">`, `<nav role="navigation">`, or `<input required aria-required="true">`.- **Caveat**: Safari removes list semantics from `<ul>`/`<ol>` outside `<nav>` when `list-style: none` or `display: flex`/`grid` is applied. In that case `role="list"` is required to restore them.++### ARIA roles and states++- **Match ARIA implementations to actual behavior**: If you set `role="tab"`, the element must behave like a tab — including keyboard interactions. Many ARIA patterns can't be implemented in CSS alone and need JavaScript.+- **Manage Toggle States**: Utilize `aria-expanded` and `aria-pressed` to communicate toggle states for custom controls.+- **Be deliberate about `disabled` vs `aria-disabled`**: `disabled` removes the element from the focus order entirely (and `tabindex="0"` won't bring it back), which is often wrong for toolbar buttons or links. `aria-disabled="true"` keeps the element focusable so users can land on it and learn it's disabled.+- **Don't hide interactive elements from screen readers**: Avoid `aria-hidden="true"` or `role="presentation"` on elements that can receive focus.- **Don't assume custom elements have no ARIA**: Custom elements can attach ARIA via `ElementInternals`, which some automated test tools can't see — so the absence of `role`/`aria-*` attributes in markup doesn't prove the element has no semantics. Verify with the browser's accessibility-tree inspector.## 3. Accessible Names and DescriptionsEvery interactive element and some landmarks need an accessible name, and many benefit from an accessible description. Names are short and identify the element; descriptions add context.-### Actionable Guidelines+### Naming mechanisms-#### DOs- **Prefer native naming mechanisms**: `<label>` for form controls, `<caption>` for `<table>`, `<legend>` for `<fieldset>`, `<figcaption>` for `<figure>`.- **Explicitly associate `<label>` with its control via `for`/`id`**, even when nesting the input inside the label — explicit association improves assistive-tech support.- **Prefer `aria-labelledby` over `aria-label` when a visible label exists**: avoids duplication, improves maintainability, and translates better.+- **Don't use `title` or `placeholder` as a naming mechanism.**+- **Don't put `aria-label`/`aria-labelledby` on elements that shouldn't be named** — e.g. plain `<div>`, `<span>`, or custom elements without a role. Custom elements may have an implicit role set via `ElementInternals`, so the absence of a `role` attribute isn't conclusive.++### Choosing the name+- **Prefer to reuse the same accessible name for hyperlinks that share an `href`.**- **Use visually hidden text to disambiguate controls** that look identical visually but do different things (e.g. multiple "Edit" buttons in a list).--#### DON'Ts-- **Don't put `aria-label`/`aria-labelledby` on elements that shouldn't be named** — e.g. plain `<div>`, `<span>`, or custom elements without a role. Custom elements may have an implicit role set via `ElementInternals`, so the absence of a `role` attribute isn't conclusive.- **Don't reuse an accessible name across controls with different effects in the same view** (close buttons for two different open dialogs are fine because only one is reachable at a time; multiple “Edit” buttons for different content is not).- **Don't reuse an accessible name across hyperlinks pointing to different `href`s.**- **Don't pack descriptions, error messages, or instructions into the label.**- **Don't repeat state already exposed via ARIA** (`aria-expanded`, `aria-checked`, `aria-selected`, `aria-pressed`) inside the accessible name — it creates redundancy and ambiguity.- **Don't include the role name in the label**: `<nav aria-label="Primary navigation">` reads as "Primary navigation navigation."-- **Don't use `title` or `placeholder` as a naming mechanism.**++### Descriptions+- **Don't include interactive elements in an `aria-describedby` target** unless their text content reads sensibly as a description on its own (e.g. if a link’s text is the same as how it’s labelled elsewhere, it can be included within a description).### Code Example: Visually Hidden Utility@@ -119,19 +183,20 @@ When the hidden content is focusable (skip links, focus-receiving wrappers), the## 4. Document Metadata and Language-### Actionable Guidelines+### Language-#### DOs- **Declare Visual Language**: Always set `<html lang="en">` (or appropriate code).-- **Unique Page Titles**: Front-load unique context in `<title>` (e.g., `Page Topic | Site Name`).- **Inline Language Switches**: Use `lang="..."` for block quotes or text in different languages.-- **IFrame Titles**: Always provide a descriptive `title="..."` for `<iframe>` elements.++### Titles++- **Unique Page Titles**: Front-load unique context in `<title>` (e.g., `Page Topic | Site Name`).- **Update document title on Page Transitions in SPAs**: Shift focus to updated titles.-#### DON'Ts-- **Don't Disable iframe Scrolling**: Avoid `scrolling="no"` (deprecated) or `overflow: hidden` on iframes. Users who zoom in or enlarge text need to scroll to reach content that overflows.+### Iframes-### Code Examples+- **IFrame Titles**: Always provide a descriptive `title="..."` for `<iframe>` elements.+- **Don't Disable iframe Scrolling**: Avoid `scrolling="no"` (deprecated) or `overflow: hidden` on iframes. Users who zoom in or enlarge text need to scroll to reach content that overflows.```html<!-- Good: Distinct title and language declaration -->@@ -148,35 +213,15 @@ When the hidden content is focusable (skip links, focus-receiving wrappers), the## 5. Keyboard and Focus Management-### Actionable Guidelines+### Tab order and focusability-#### DOs- **Logical Tab Order**: Ensure tab order matches visual layouts (top-to-bottom).-- **Visible Focus Indicators**: Always style `:focus-visible` states explicitly. If disabling defaults, provide overrides with sufficient contrast.-- **Custom Trigger Keyboards**: Attach Enter/Space handlers for custom simulated interactive elements. When implementing a custom keyboard handler for button-like elements, `Enter` should be a `keydown` handler and `Space` should be a `keyup` handler (matching native `<button>` behavior where `Enter` repeats and `Space` triggers on release).- **Use `tabindex` deliberately**: Anything focusable — by keyboard or programmatically — should have an implicit or explicit ARIA role, so don't make every element focusable. When focus is needed, choose `tabindex="0"` to add the element to the tab order or `tabindex="-1"` to make it programmatically focusable only (e.g., a skip-link target).-- **Manage Toggle States**: Utilize `aria-expanded` and `aria-pressed` to communicate toggle states for custom controls.--#### DON'Ts-- **Don't disable outlines without replacements**: Avoid `outline: none` without styling alternatives.- **Don't use Positive Tabindex values**: Never use `tabindex="1"` or greater.-- **Don't hide interactive elements from screen readers**: Avoid `aria-hidden="true"` or `role="presentation"` on elements that can receive focus.-### Code Examples+### Keyboard handlers-```css-/* Good: High contrast focus border */-:where(a:any-link, button):focus-visible {- outline: 3px solid #ff0055;- outline-offset: 3px;-}-```--```html-<!-- Good: Skip to main content -->-<a href="#content" class="skip-link">Skip to main content</a>-<main id="content" tabindex="-1">...</main>-```+- **Custom Trigger Keyboards**: Attach Enter/Space handlers for custom simulated interactive elements. When implementing a custom keyboard handler for button-like elements, `Enter` should be a `keydown` handler and `Space` should be a `keyup` handler (matching native `<button>` behavior where `Enter` repeats and `Space` triggers on release).```javascript// Good: Keyboard handlers for complex custom widgets (e.g., Tree items, tabs).@@ -205,51 +250,82 @@ function toggleWidgetState() {}```+### Focus indicators++- **Visible Focus Indicators**: Always style `:focus-visible` states (not `:focus`) explicitly. If disabling defaults, provide overrides with sufficient contrast.+- **Don't disable outlines without replacements**: Avoid `outline: none` without styling alternatives.+- Prefer `outline` over other properties (e.g. `box-shadow`) for focus rings. If you must rely on `box-shadow` for focus rings, provide an `outline`-based fallback for High Contrast Mode using the `forced-colors` media query.+- Pair focus outlines with `outline-offset` to visually separate the ring from the element.++```css+/* Good: High contrast focus border */+:where(a:any-link, button):focus-visible {+ outline: 3px solid #ff0055;+ outline-offset: 3px;+}+```++### Touch targets++- Interactive elements should be at least 24×24 CSS pixels (WCAG 2.5.8 AA). Enforce with `min-block-size` / `min-inline-size` or padding rather than `width` / `height`, so content can grow the target but not shrink it.+- Bump targets up on coarse pointers: `@media (pointer: coarse) { ... }`.+- **DON'T** use `touch-action: none` for custom gestures — it disables page scrolling through the element. Scope to the axis you actually need: `pan-y` for horizontal swipes (page still scrolls vertically), `pan-x` for vertical ones. Reserve `none` for elements where no native touch behavior makes sense (e.g. a drawing canvas).+## 6. Alternate Text and Media-### Actionable Guidelines+### Images-#### DOs- **Informative Visual Descriptions**: Describe the purpose of the image (e.g., "Search", not "Magnifying glass").- **Empty Alt properties for decorative visuals**: Use `alt=""` to remove decorative images from the accessibility tree so they aren't announced.-- **Synchronous Captions for videos**: Supply WebVTT captions for video tracks.-- **Transcripts for audio**: Provide text transcripts for purely audio podcasts.-- **Informative View Descriptions for inline SVGs**: Apply `role="img"` and a nested `<title>` tag for informative visuals.-- **Decorative SVGs removal**: Apply `aria-hidden="true"` to remove decorative SVGs from reading flows.-- **Long descriptions for complex images**: Use `<figure>`/`<figcaption>` or `aria-describedby` for charts and infographics.-- **Provide data tables as alternatives**: Consider providing semantic data tables as accessible alternatives for charts and other complex data visualizations.--#### DON'Ts- **Don't use clichéd prefixes**: Avoid "Image of..." or "Picture of...".- **Don't use underscores in filenames**: Use dashes if the filename might be announced as fallback.-### Code Examples-```html<!-- Decorative --><img src="divider.png" alt="">+<!-- Informative (Functional) -->+<a href="/search">+ <img src="glass.png" alt="Search the platform">+</a>+```++### Inline SVGs++- **Informative View Descriptions for inline SVGs**: Apply `role="img"` and a nested `<title>` tag for informative visuals.+- **Decorative SVGs removal**: Apply `aria-hidden="true"` to remove decorative SVGs from reading flows.++```html<!-- Inline Decorative SVG (remove from tab flow) --><svg aria-hidden="true" viewBox="0 0 24 24"><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>+```-<!-- Informative (Functional) -->-<a href="/search">- <img src="glass.png" alt="Search the platform">-</a>+### Complex images and charts-<!-- Video with Captions tracks -->-<video controls>- <source src="intro.mp4" type="video/mp4">- <track src="caps.vtt" kind="captions" srclang="en" label="English">-</video>+- **Long descriptions for complex images**: Use `<figure>`/`<figcaption>` or `aria-describedby` for charts and infographics.+- **Provide data tables as alternatives**: Consider providing semantic data tables as accessible alternatives for charts and other complex data visualizations.+```html<!-- Complex graph with figcaption --><figure><img src="chart.png" alt="Sales growth graph 2024."><figcaption>Sales grew 20% in Q3 due to new platform launch.</figcaption></figure>+```++### Audio and video++- **Synchronous Captions for videos**: Supply WebVTT captions for video tracks.+- **Transcripts for audio**: Provide text transcripts for purely audio podcasts.++```html+<!-- Video with Captions tracks -->+<video controls>+ <source src="intro.mp4" type="video/mp4">+ <track src="caps.vtt" kind="captions" srclang="en" label="English">+</video><!-- Audio with expandable transcript details --><audio controls src="podcast.mp3" aria-details="podcast-transcript"></audio>@@ -261,6 +337,10 @@ function toggleWidgetState() {</details>```+### CSS generated content++- **Alt text for CSS generated content**: Use the alternative text argument of `content` (e.g. `content: url(icon.svg) / "Save";`) and keep meaningful text in the DOM. See `accessible-generated-content` (via `npx -y modern-web-guidance@latest retrieve "accessible-generated-content"`) for more details.+### Content Visibility Decision Matrix| Intent | Visual | Screen Reader | Focusable | Structural Pattern |@@ -274,20 +354,11 @@ function toggleWidgetState() {## 7. Forms and Input Controls-### Actionable Guidelines+### Labels and hints-#### DOs- **Connect Labels Programmatically**: Use `<label for="id">` linked to `<input id="id">`.-- **Use Autocomplete**: Set valid standard `autocomplete` options (e.g., `"email"` or `"given-name"`) for user profiles.-- **Link hints to inputs via `aria-describedby`**: Associate help text with inputs, and place the hint above the input so autocomplete popovers don't cover it during editing.-- **Announce dynamic errors via live regions**: Use `aria-live` or shift focus to error lists.-- **Provide form validation constraints**: Use `required` (or `aria-required="true"` only when `required` isn't applicable) to signal mandatory inputs.--#### DON'Ts- **Don't use placeholders as labels**: Placeholders are not persistent labels.-- **Don't trigger context shifts on focus changes**: Avoid auto-submitting forms or jumping pages on focus change events alone.--### Code Examples+- **Link hints to inputs via `aria-describedby`**: Associate help text with inputs, and place the hint above the input so autocomplete popovers don't cover it during editing.```html<!-- Good: Semantic forms with hints for passwords -->@@ -298,6 +369,13 @@ function toggleWidgetState() {</form>```+### Input assistance and validation++- **Use Autocomplete**: Set valid standard `autocomplete` options (e.g., `"email"` or `"given-name"`) for user profiles.+- **Provide form validation constraints**: Use `required` (or `aria-required="true"` only when `required` isn't applicable) to signal mandatory inputs.+- **Don't trigger context shifts on focus changes**: Avoid auto-submitting forms or jumping pages on focus change events alone.++## 8. Live RegionsLive regions let assistive tech announce content updates that aren't tied to navigation or focus changes. They're easy to misuse — too many regions, or noisy ones, quickly become spam for screen-reader users.@@ -312,126 +390,47 @@ Live regions let assistive tech announce content updates that aren't tied to nav**Heuristic Rule**: Use `assertive` only for critical, time-sensitive updates that require immediate attention or prevent safe continuation (e.g., data loss, session timeouts, or network drops).-### Actionable Guidelines--#### DOs-- **Centralize live regions for non-visible announcements**: A single `polite` region and a single `assertive` region per page (with whatever `aria-atomic` configuration you need) keeps announcements consistent and easier to maintain. Many frameworks ship their own announcer abstraction — use it.-- **Debounce frequently-changing regions**: If a region can update many times per second (e.g. a combobox's result count as the user types), debounce so users aren't spammed.-- **Delay slightly when other announcements may collide**: When the user is typing or focus is being managed, a small delay before announcing keeps live-region updates from overlapping other speech.+### When to announce-#### DON'Ts+- **Announce dynamic errors via live regions**: Use `aria-live` or shift focus to error lists.- **Don't use live regions for interstitial states** like "Loading…" or "Updating…" unless they're meaningfully informative — they usually just create noise.-- **Don't add live-region updates to inert DOM**: When dialogs open or sections become `inert`, queued or debounced messages can end up unannounced — or announced from DOM the user can't reach. Coordinate live-region updates with dialog/inert state changes.--### Code Example```html<!-- Session Timeout Warning with controls --><div role="alert" class="timeout-warning">- Your session will expire in 2 minutes.+ Your session will expire in 2 minutes.<button type="button" onclick="extendSession()">Extend Session</button></div>```-## 9. Color, Contrast, and Typography--### Actionable Guidelines--#### DOs-- **Minimum contrast standards**: Maintain 4.5:1 for normal text and 3:1 for large text or icons.-- **Ensure non-text contrast standards**: Maintain a minimum contrast ratio of 3:1 for user interface component boundaries and states.- - This includes visual elements (borders, backgrounds, box-shadows, underlines) that form the boundary or indicate the presence of a UI component (e.g., input field borders).- - This also includes visual elements indicating active states within a component (e.g., checkbox checkmarks or switch thumbs).- - **Caveat**: Meeting 3:1 non-text contrast can challenge minimalistic designs. Soft gradients or subtle inset/outset shadows can soften visual boundaries while satisfying accessibility requirements.-- **Use multiple state indicators**: Do not denote success/errors ONLY with color. Use icons or text.-- **Relative font size units**: Use `rem` or `em` for font sizes instead of `px`.-- **Consistent or Start alignment**: Avoid `justify` alignment as it can be more difficult to read.-- **Avoid long lines of text**: Cap paragraph blocks to a maximum of 80 characters width.-- **Support user zoom preferences**: Allow users to resize text up to 200% without loss of content or functionality.-- **Support light and dark color schemes**: Honor `@media (prefers-color-scheme: dark)` and pair it with the `color-scheme` CSS property so form controls, scrollbars, and other UA-rendered surfaces match.-- **Use `prefers-contrast` only when warranted**: Reach for `@media (prefers-contrast: more)` when the design uses low-contrast accents (e.g., subtle borders, muted secondary text) that need to be reinforced; most sites that already meet baseline contrast won't need it.--#### DON'Ts-- **Don't use color alone to indicate the presence of a user interface component or its state**: Use iconography and/or shape to help differentiate.-- **Don't use Justified Text Alignment**: Avoid `text-align: justify`.-- **Don't use Ornate fonts**: Omit cursive typefaces for main reading content.-- **Don't rely on all-caps for emphasis**: Prefer bolding for visual emphasis, and use `<em>`/`<strong>` when the emphasis is semantic.-- **Limit emphasis overall**: Emphasis loses meaning when it's everywhere — apply it only where it changes how the content should be read.--### Code Examples+### Managing announcements-```css-/* Good: Relative sizing and line caps */-body {- line-height: 1.5;- text-align: start; /* Supports LTR and RTL */-}-article {- max-width: 80ch; /* Caps line length to ~80 characters for readability */-}-```--```html-<!-- Good: Denotes state without colors alone -->-<div class="error-msg">- <span aria-hidden="true">❌</span>- <span>The password entered was invalid.</span>-</div>-```--```css-/* Dark Mode support variables */-:root {- --bg-color: #ffffff;- --text-color: #212529;-}-@media (prefers-color-scheme: dark) {- :root {- --bg-color: #121212;- --text-color: #f8f9fa;- }-}-```+- **Centralize live regions for non-visible announcements**: A single `polite` region and a single `assertive` region per page (with whatever `aria-atomic` configuration you need) keeps announcements consistent and easier to maintain. Many frameworks ship their own announcer abstraction — use it.+- **Debounce frequently-changing regions**: If a region can update many times per second (e.g. a combobox's result count as the user types), debounce so users aren't spammed.+- **Delay slightly when other announcements may collide**: When the user is typing or focus is being managed, a small delay before announcing keeps live-region updates from overlapping other speech.+- **Don't add live-region updates to inert DOM**: When dialogs open or sections become `inert`, queued or debounced messages can end up unannounced — or announced from DOM the user can't reach. Coordinate live-region updates with dialog/inert state changes.-## 10. Motions and Preferences+## 9. Color-### Actionable Guidelines+See `color` (via `npx -y modern-web-guidance@latest retrieve "color"`) for accessible color (contrast requirements, light and dark color schemes, Forced Colors Mode, etc).-#### DOs-- **Support Reduced Motion media queries**: Support `@media (prefers-reduced-motion: reduce)` media queries.-- **Provide Pause mechanism**: Allow users to stop auto-running carousels banners or other persistent animations.-- **Default to static views**: Consider defaulting to static states and allowing users to opt-in to motion.+## 10. Typography-#### DON'Ts-- **Don't exceed flash limits (three per second)**: Never include rapid light-to-dark flashing. Such effects can cause seizures.+See `typography` (via `npx -y modern-web-guidance@latest retrieve "typography"`) for readable typography.-### Code Examples+## 11. Motion and Preferences-```css-/* Good: Dampen spin states for reduced motion queries */-@media (prefers-reduced-motion: reduce) {- .spinner {- animation: none;- opacity: 0.5;- }-}-```+See `motion` (via `npx -y modern-web-guidance@latest retrieve "motion"`).-## 11. Modals and Native Dialogs+## 12. Modals and Native DialogsModern browsers provide native solutions for creating modal dialogs which avoid the need for focus traps, managing the accessibility of outside content, ensuring the content is on top, and dimming the background content — all of which can be error prone and require heavy JavaScript event tracking to maintain.-### Actionable Guidelines+### Native `<dialog>`-#### DOs- **Use the Native `<dialog>` Element**: Invoke the dialog using the `.showModal()` method to open it in a modal state. When in a modal state, the browser sets outside content as inert (i.e. the outside content is hidden from the accessibility tree and cannot be interacted with nor be focused).-- **Use the `inert` Attribute for Custom Overlays**: When `<dialog>` cannot be used (e.g., some non-modal overlays, framework constraints, or layouts where `<dialog>`'s top-layer/positioning behavior conflicts with the design), apply `inert` to outside content to ensure it cannot be interacted with by keyboard, pointer, or assistive technology. This requires structuring elements in such a way that the custom overlay is not a descendant of the element with `inert` set on it.--#### DON'Ts- **Don't implement focus traps for native modal dialogs**: When a `<dialog>` element is opened in a modal state, browsers set outside content as inert which is sufficient for ensuring only the dialog’s content can be focused.-### Code Examples-**HTML & JS: Native `<dialog>` with standard close events**```html<!-- Dialog opens natively with showModal() and locks focus -->@@ -450,14 +449,19 @@ Modern browsers provide native solutions for creating modal dialogs which avoid</script>```-## 12. Testing Validations+### Custom overlays++- **Use the `inert` Attribute for Custom Overlays**: When `<dialog>` cannot be used (e.g., some non-modal overlays, framework constraints, or layouts where `<dialog>`'s top-layer/positioning behavior conflicts with the design), apply `inert` to outside content to ensure it cannot be interacted with by keyboard, pointer, or assistive technology. This requires structuring elements in such a way that the custom overlay is not a descendant of the element with `inert` set on it.+++## 13. Testing Validations-### Actionable Guidelines+### Automated checks-#### DOs- **Run Automated checks via axe-core or Lighthouse audits**: Catch missing alt texts or low contrasts (e.g., via Lighthouse in Chrome DevTools MCP).+- **Don't rely purely on scores**: A 100% score does not guarantee real usability.++### Manual testing+- **Validate Sequential Navigations using keyboards alone**: Using only keyboard shortcuts, such as Tab/Shift+Tab, arrow keys, Enter, Space, and Esc, confirm every interactive element is reachable and operable, and that focus never gets stuck.- **Test on Screen Readers with calibrated browsers**: Rely on standard bindings (e.g., JAWS with Chrome, NVDA with Firefox, Narrator with Edge, VoiceOver with Safari on macOS and iOS, TalkBack with Chrome for Android).--#### DON'Ts-- **Don't rely purely on scores**: A 100% score does not guarantee real usability.diff --git a/skills/modern-web-guidance/guides/accessibility/accessible-generated-content.md b/skills/modern-web-guidance/guides/accessibility/accessible-generated-content.mdnew file mode 100644index 0000000..e1dcf23--- /dev/null+++ b/skills/modern-web-guidance/guides/accessibility/accessible-generated-content.md@@ -0,0 +1,23 @@+# Accessible generated content++- **DON'T** use `content` to convey meaningful text (labels, state, instructions) — keep that in the DOM (WCAG F87). The alt text argument is harm reduction for cases where decoration accidentally carries meaning, not a license.+- Use the alternative text argument of `content` to provide alt text for screen readers. E.g. `content: url(cloud.svg) / "Save";`+- Use `content: "text" / "";` to prevent purely decorative text from being announced to screen readers.+- **DON'T** use an empty alt text argument for images — they're already presentational by default. E.g. this is wrong: `content: url(cloud.svg) / "";`.+- **DON'T** use the alt text argument to describe emojis unless the description differs from the official emoji name. E.g. don't do `content: "🎉" / "celebration";`, but `content: "🎉" / "Yay!";` is fine.++**ONLY** use the alt text argument when the text is different than the primary value and is not already present in the DOM. I.e. this is wrong:++HTML:+```html+<button class="save">Save</button>+```++CSS:+```css+button.save::before {+ content: url(cloud.svg) / "Save";+}+```++A screen reader would read it out as "Save save".diff --git a/skills/modern-web-guidance/guides/accessibility/respect-os-text-scale.md b/skills/modern-web-guidance/guides/accessibility/respect-os-text-scale.mdnew file mode 100644index 0000000..4ed7506--- /dev/null+++ b/skills/modern-web-guidance/guides/accessibility/respect-os-text-scale.md@@ -0,0 +1,127 @@+# Respect Operating System Text Scale++## Overview++Users with visual impairments often configure text scaling at the operating system level (such as Dynamic Type on iOS or Font Size scaling on Android/ChromeOS). By default, mobile browsers ignore these OS-level accessibility settings to prevent legacy, fixed-pixel websites from breaking visually.++Instead of keeping your page static or relying on custom, fragile JavaScript layout calculations, opt into native operating system text scaling using the `<meta name="text-scale">` tag. When active, the browser dynamically scales the root font size (`1rem`) to match the user's OS preference, allowing all relative (`rem`/`em`) font sizes, layouts, and spacing to scale automatically and gracefully.++## Implementation++### 1. Opt Into OS Text Scaling++Place the `<meta name="text-scale">` element inside your document's `<head>`. This signals to supporting browsers that your layout is modern, adaptive, and safe to scale:++```html+<head>+ <meta charset="UTF-8" />+ <meta name="viewport" content="width=device-width" />++ <!-- Opt this page into OS-level dynamic type and accessibility text scaling -->+ <meta name="text-scale" content="scale" />++ <title>Adaptive Accessibility Layout</title>+</head>+```++### 2. Use Relative Typography & Spacing++Define font sizes using relative units (`rem` or `em`) rather than fixed pixels (`px`). Use unitless values for line heights so they scale proportionally with each element's computed font size.++Use relative units for margins and padding where the spacing is coupled to text size or must adapt as text is scaled. Spacing that is independent of text may use fixed units when appropriate, provided that scaling does not cause text clipping, overlap, loss of content, or an unusable layout:++```css+body {+ font-family: system-ui, sans-serif;+ /* Inherits the root font-size, which scales automatically with the OS setting */+ line-height: 1.5; /* Unitless so it scales proportionally with computed font-size */+ padding: 1.5rem; /* Scales proportionally to prevent dense crowding at larger scales */+}++h1 {+ font-size: 2.25rem; /* Scales proportionally to the root base */+ margin-bottom: 1rem;+}+```++Set the base text size on `body` only when the design needs a size different from the inherited browser default; otherwise, let it inherit. Set sizes on specific elements, such as headings, with relative units such as `rem` or `em`. Use `rem` for a size relative to the root font size, and `em` when the size should depend on the parent element's font size. Do not set a custom font size on `:root` or `html`.++#### Fluid Typography++Fluid typography MAY use viewport-relative units such as `vw`, provided that font sizes also include a font-relative component such as `rem` or `em`. For more fluid-scaling techniques, including container query units and `clamp()`, see `fluid-scaling` (via `npx -y modern-web-guidance@latest retrieve "fluid-scaling"`).++Avoid sizing text exclusively with viewport units:++```css+/* ❌ DO NOT DO THIS: The font size does not respond fully to user text scaling */+.heading {+ font-size: 5vw;+}+```++Instead, combine a font-relative value with viewport-relative scaling and use relative minimum and maximum bounds:++```css+.heading {+ font-size: clamp(2rem, 1.25rem + 2vw, 4rem);+}+```++Test that text can be resized to at least 200% of its default size without loss of content or functionality. For fluid typography, a useful rule of thumb is to keep the maximum font size no more than 2.5 times the minimum. Also test reflow at a 320 CSS-pixel viewport width (equivalent to 400% zoom from a 1280 CSS-pixel-wide viewport); content MUST remain available without two-dimensional scrolling, except where essential.++### 3. Use Scalable Responsive Breakpoints++Responsive breakpoints MUST NOT assume that text will remain at its default size. Where a breakpoint is intended to respond to available space for text, prefer content-driven layouts, container queries, or `em`-based media queries rather than fixed pixel thresholds.++Test responsive layouts with operating system text scaling and browser zoom enabled. Text MUST remain readable and content MUST remain visible without overlap, clipping, or horizontal scrolling.++### 4. Ensure Content Wrapping & Flexible Heights++When text scales up, elements require more vertical and horizontal space to prevent truncation or overlap. To keep your components robust, design your layouts to expand dynamically around the content rather than forcing rigid coordinates:++* **Allow Text Containers to Grow**: Text-containing components and containers MUST be able to grow to accommodate scaled text. Avoid fixed `height` or `block-size` values and restrictive `max-height` or `max-block-size` values that can cause clipping or overflow. Prefer content-driven sizing; use `min-height` or `min-block-size` only when a minimum size is needed.+* **Allow Natural Wrapping**: Do not restrict inline-axis text wrapping with `white-space: nowrap` on blocks that contain sentences. Let text reflow to new lines naturally.+* **Employ Flexible Flexbox & Grid wrapping (Optional Example)**: For multi-column card galleries, use reflowing columns like `repeat(auto-fit, minmax(min(100%, 16rem), 1fr))` so items stack vertically if their relative width thresholds are crossed:++```css+/* Card container using min-height to ensure expansion and auto-fit to reflow if needed */+.card {+ padding: 1.5rem;+ border: 1px solid #ccc;+ border-radius: 8px;+ /* Use min-height so the box expands vertically when the font is enlarged */+ min-height: 10rem;+}+```++### 5. DO NOT Override the Root Font Size++When opting in via the `<meta name="text-scale" content="scale">` element, **DO NOT** explicitly set the root `font-size` in your stylesheet. This includes declarations on either `:root` or `html`, and applies to absolute units, relative units, and calculated values.++For example, do not override the root font size with a fixed value:++```css+/* ❌ DO NOT DO THIS: This can prevent the browser from applying text scaling */+html {+ font-size: 16px;+}+```++Do not combine the `<meta name="text-scale" content="scale">` opt-in with `env(preferred-text-scale)` to apply operating system text scaling manually. The browser applies the scale through the meta opt-in, so using both can result in double-scaling:++```css+/* ❌ DO NOT DO THIS: The meta opt-in already applies the operating system text scale */+:root {+ font-size: calc(1rem * env(preferred-text-scale));+}+```++Leave the root font size to the browser. The browser handles the operating system text scale automatically and applies it to content sized relative to the root font size.++## Fallback Strategies++Browser support for <meta name="text-scale">: Limited availability.+Supported by: Chrome 146 (Mar 2026) and Edge 146 (Mar 2026).+Unsupported in: Firefox and Safari.++On browsers where `<meta name="text-scale" content="scale">` is unsupported, the layout degrades gracefully. The page will display the layout at the browser's standard default base font size (typically 16px), and the user can still utilize standard manual page zoom or pinch-to-zoom options.diff --git a/skills/modern-web-guidance/guides/built-in-ai/language-detection.md b/skills/modern-web-guidance/guides/built-in-ai/language-detection.mdindex f6ca86e..4c156bf 100644--- a/skills/modern-web-guidance/guides/built-in-ai/language-detection.md+++ b/skills/modern-web-guidance/guides/built-in-ai/language-detection.md@@ -72,7 +72,7 @@ Avoid using the detector on very short phrases or single words, as accuracy drop## Fallback Strategy-Language detector has limited availability.+Browser support for Language detector: Limited availability.Supported by: Chrome 138 (Jun 2025) and Edge 148 (May 2026).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/built-in-ai/language-model.md b/skills/modern-web-guidance/guides/built-in-ai/language-model.mdindex f333729..88ec832 100644--- a/skills/modern-web-guidance/guides/built-in-ai/language-model.md+++ b/skills/modern-web-guidance/guides/built-in-ai/language-model.md@@ -348,7 +348,7 @@ This optimizes responsiveness and efficient use of local compute.## 6. Fallback strategies-LanguageModel has limited availability.+Browser support for LanguageModel: Limited availability.Supported by: Chrome 148 (May 2026).Unsupported in: Edge, Firefox, and Safari.diff --git a/skills/modern-web-guidance/guides/built-in-ai/prompt-api.md b/skills/modern-web-guidance/guides/built-in-ai/prompt-api.mdindex f333729..88ec832 100644--- a/skills/modern-web-guidance/guides/built-in-ai/prompt-api.md+++ b/skills/modern-web-guidance/guides/built-in-ai/prompt-api.md@@ -348,7 +348,7 @@ This optimizes responsiveness and efficient use of local compute.## 6. Fallback strategies-LanguageModel has limited availability.+Browser support for LanguageModel: Limited availability.Supported by: Chrome 148 (May 2026).Unsupported in: Edge, Firefox, and Safari.diff --git a/skills/modern-web-guidance/guides/built-in-ai/summarizer.md b/skills/modern-web-guidance/guides/built-in-ai/summarizer.mdindex e76b895..f8c5926 100644--- a/skills/modern-web-guidance/guides/built-in-ai/summarizer.md+++ b/skills/modern-web-guidance/guides/built-in-ai/summarizer.md@@ -132,7 +132,7 @@ for await (const chunk of stream) {## Fallback Strategy-Summarizer has limited availability.+Browser support for Summarizer: Limited availability.Supported by: Chrome 138 (Jun 2025) and Edge 138 (Jun 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/built-in-ai/translator.md b/skills/modern-web-guidance/guides/built-in-ai/translator.mdindex 38fb76f..a9b8229 100644--- a/skills/modern-web-guidance/guides/built-in-ai/translator.md+++ b/skills/modern-web-guidance/guides/built-in-ai/translator.md@@ -165,7 +165,7 @@ The API supports a wide range of BCP 47 language codes: Here are the languages s## Fallback Strategy-Translator has limited availability.+Browser support for Translator: Limited availability.Supported by: Chrome 138 (Jun 2025) and Edge 148 (May 2026).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/css/animate-to-intrinsic-sizes.md b/skills/modern-web-guidance/guides/css/animate-to-intrinsic-sizes.mdindex 6b7302a..5a94c61 100644--- a/skills/modern-web-guidance/guides/css/animate-to-intrinsic-sizes.md+++ b/skills/modern-web-guidance/guides/css/animate-to-intrinsic-sizes.md@@ -106,11 +106,11 @@ triggerBtn?.addEventListener('click', () => {## Fallback strategies-interpolate-size has limited availability.+Browser support for interpolate-size: Limited availability.Supported by: Chrome 129 (Sep 2024) and Edge 129 (Sep 2024).Unsupported in: Firefox and Safari.-calc-size() has limited availability.+Browser support for calc-size(): Limited availability.Supported by: Chrome 129 (Sep 2024) and Edge 129 (Sep 2024).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/css/atrule-support-conditionals.md b/skills/modern-web-guidance/guides/css/atrule-support-conditionals.mdnew file mode 100644index 0000000..9d17dbe--- /dev/null+++ b/skills/modern-web-guidance/guides/css/atrule-support-conditionals.md@@ -0,0 +1,148 @@+# Conditionally Apply CSS Based on At-Rule Support++Use `@supports at-rule(@<at-rule name>) {…}` to conditionally apply certain CSS rules or declarations only if a certain at-rule is supported by the browser.+This can contain entire rules, or be used in conjunction with CSS nesting to conditionally apply certain declarations.++```css+.foo {+ background: var(--accent-color);++ @supports at-rule(@property) {+ background-image: var(--rainbow-gradient);+ animation: sliding-rainbow 1s linear infinite;+ }+}+```++Do NOT use `@supports at-rule()` to conditionally apply the at-rule being detected and nothing else.++```css+/* BAD: CSS already ignores rules the browser doesn't understand, so this is unnecessary */+@supports at-rule(@starting-style) {+ @starting-style {+ /* ... */+ }+}+```++## Detecting support for at-rules when `@supports at-rule()` isn’t appropriate { #detecting-at-rules-without-supports-at-rule }++When `at-rule()` is not an option, either due to browser support or because deeper detection is needed, you can use the guidance below.++### Try properties, values, or selectors first++`@supports` can already detect properties, values, and selectors (via `@supports selector(...)`).+In many cases, you can use these to detect support for a feature without needing to check for the at-rule itself.++For example, instead of `@supports at-rule(@function)` to detect supports for custom functions, you can use `@supports (color: --foo())`.++In other cases there may be pseudo-classes or pseudo-elements that are only available when a certain at-rule is supported, which can be used to detect support.++### Detecting container query types { #supports-container-types }++`at-rule()` ONLY allows detection of at-rules by **name**.+It does NOT allow detection of other syntax or descriptors.+E.g. this will not work:++```css+@supports at-rule(@container style(--a: 1)) {+ /* ... */+}+```++For many types of container queries, you can use `container-type` with a suitable value.+E.g. `@supports (container-type: scroll-state)` for scroll-state queries or `@supports (container-type: size)`container-type: anchored` for `anchored()` queries.++However, there is no `container-type` for style queries.+IMPORTANT: Do NOT try `@supports (container-type: style)` to detect support for style queries, as this will not work.++Instead, you can try a style query that is always true:++```css+@container style(--a: 1) or (not (style(--a: 1))) {+ /* Rules here will only be applied if style queries are supported */+}+```++This will match in any browser that supports style queries, regardless of what property name or value you use, provided they are the same across both.++### Registered custom properties (`@property`) { #supports-atproperty }++In some cases, if the conditional CSS to apply can be reduced to a single property, you can use a dedicated custom property registered for this purpose:++```css+/* Use a custom property to conditionally include the dash animation */+@property --progress-dash-animation {+ syntax: "*";+ inherits: false;+ initial-value: , progress-dash 3s ease-in-out infinite;+}++.spinner {+ /* The dash animation is only included if @property is supported */+ animation:+ progress-spin var(--_used-spinner-duration) linear infinite+ var(--progress-dash-animation, );+}+```+++For a more general-purpose solution, you can register a non-inheriting property and set it to ` ` (a space) on the root element:++{# Testcase: https://codepen.io/leaverou/pen/KwWzpVr #}++```css+@property --supports-atproperty {+ syntax: "*";+ inherits: false;+}++:root {+ --supports-atproperty: ;+}++body {+ /* The background is only applied if @property is supported */+ background: var(--supports-atproperty, green);+}+```++Notes:+- Both of these only work if whitespace is an acceptable alternative. For other cases, you will need to use JS as described below.+- The general-purpose solution depends on non-inheritance, so it will not work for declarations on the root element.++### Using JavaScript as a last resort++For entire at-rules, check for the presence of certain interfaces in JavaScript.+For example, if `globalThis.CSSFunctionRule` is defined, then `@function` is supported.++If you need to test more deeply (e.g. for certain preludes, nested rules, descriptors), you can set up a test and check how it was parsed:++```js+const sheet = new CSSStyleSheet();+sheet.replaceSync(`+ @page {+ @top-left {+ content: "test";+ }+ }+`);+const SUPPORTS_PAGE_MARGINS = Boolean(sheet.cssRules[0]?.cssRules?.[0]);+```++IMPORTANT:+- When using JS to detect support for CSS features, do NOT apply the styles from JS directly. Instead, apply a class to the root element and branch off that in CSS.+- Do note that container queries are parsed even if the prelude is not recognized, and there is no way to detect support for certain types of container queries from the CSSOM structure.+- Do NOT use `CSS.registerProperty` to detect support for `@property` as its support is slightly broader.++## Fallback strategies++Browser support for at-rule(): Limited availability.+Supported by: Chrome 148 (May 2026) and Edge 148 (May 2026).+Unsupported in: Firefox and Safari.++Unless this is within your support target, **ONLY** use `@supports (at-rule())` to detect at-rules for which support is narrower than the `@supports (at-rule())` feature itself.++To conditionally apply CSS based on support for at-rules that shipped before this feature, use [the guidance in the section above](#detecting-at-rules-without-supports-at-rule).++To detect support for the `@supports at-rule()` feature _itself_, you can use an at-rule that is guaranteed to exist in all browsers that support `@supports at-rule()`, such as `@supports at-rule(@media) { ... }`.diff --git a/skills/modern-web-guidance/guides/css/calculate-with-intrinsic-sizes.md b/skills/modern-web-guidance/guides/css/calculate-with-intrinsic-sizes.mdindex 805c14a..128620a 100644--- a/skills/modern-web-guidance/guides/css/calculate-with-intrinsic-sizes.md+++ b/skills/modern-web-guidance/guides/css/calculate-with-intrinsic-sizes.md@@ -154,11 +154,11 @@ You can use `calc-size()` with any CSS math function—such as `min()`, `max()`,## Fallback strategies-calc-size() has limited availability.+Browser support for calc-size(): Limited availability.Supported by: Chrome 129 (Sep 2024) and Edge 129 (Sep 2024).Unsupported in: Firefox and Safari.-interpolate-size has limited availability.+Browser support for interpolate-size: Limited availability.Supported by: Chrome 129 (Sep 2024) and Edge 129 (Sep 2024).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/css/css-layout.md b/skills/modern-web-guidance/guides/css/css-layout.mdindex ef240ad..66dfc03 100644--- a/skills/modern-web-guidance/guides/css/css-layout.md+++ b/skills/modern-web-guidance/guides/css/css-layout.md@@ -209,7 +209,7 @@ Supported by: Chrome 37 (Aug 2014), Edge 79 (Jan 2020), Firefox 98 (Mar 2022), aBaseline status for Popover: Newly available. It's been Baseline since 2025-01-27.Supported by: Chrome 116 (Aug 2023), Edge 116 (Aug 2023), Firefox 125 (Apr 2024), Safari 17 (Sep 2023), and Safari iOS 18.3 (Jan 2025).-Anchor positioning has limited availability.+Browser support for Anchor positioning: Limited availability.Supported by: Safari 27.Unsupported in: Chrome, Edge, and Firefox.@@ -276,11 +276,11 @@ Supported by: Chrome 108 (Nov 2022), Edge 108 (Dec 2022), Firefox 101 (May 2022)- Use `dvh`/`dvw` for mobile layout containers that must account for browser UI shifting (URL bar collapse/expand).- Don't use `100vw` for full-width layout — it ignores scrollbar width and causes horizontal overflow. Use `100%`, `100dvw`, or `100svw` instead.-> For the full viewport unit reference (`svh`, `lvh`, `dvi`, `dvb`, etc.), see `css` (via `npx -y modern-web-guidance@latest retrieve "css"`).+> For the responsive design entry point (dynamic viewport units, reserving space for media, fluid typography), see `responsive-design` (via `npx -y modern-web-guidance@latest retrieve "responsive-design"`).## 8 Grid lanes (aka masonry)-Grid lanes has limited availability.+Browser support for Grid lanes: Limited availability.Supported by: Safari 26.4 (Mar 2026).Unsupported in: Chrome, Edge, and Firefox.diff --git a/skills/modern-web-guidance/guides/css/css.md b/skills/modern-web-guidance/guides/css/css.mdindex 55e7192..b848c9f 100644--- a/skills/modern-web-guidance/guides/css/css.md+++ b/skills/modern-web-guidance/guides/css/css.md@@ -1,35 +1,27 @@-# CSS: Modern Architecture and Performance--These guidelines provide a high-density reference for writing maintainable, performant, and standard-compliant CSS.--1. [1. Foundations](#1-foundations)-2. [2. Inheritance and The Cascade](#2-inheritance-and-the-cascade)-3. [3. Selectors and scoping](#3-selectors-and-scoping)- 1. [Prefer CSS selectors over JS for complex element targeting](#prefer-css-selectors-over-js-for-complex-element-targeting)- 2. [Use `:is()` (or `:where()`) instead of CSS rule duplication for fallbacks](#use-is-or-where-instead-of-css-rule-duplication-for-fallbacks)- 3. [Avoid overmatching](#avoid-overmatching)- 4. [Nesting and scoping](#nesting-and-scoping)-4. [4. Interactivity](#4-interactivity)- 1. [Focus management](#focus-management)- 2. [Touch targets](#touch-targets)-5. [5. Design Tokens and Theming](#5-design-tokens-and-theming)- 1. [Dark mode](#dark-mode)- 2. [Forced Colors Mode](#forced-colors-mode)- 3. [Generating tints](#generating-tints)- 4. [Theming browser-generated UI](#theming-browser-generated-ui)-6. [6. Responsive design](#6-responsive-design)- 1. [Responsive Typography](#responsive-typography)-7. [7. Typography](#7-typography)- 1. [Text wrapping](#text-wrapping)-8. [8. Visual effects](#8-visual-effects)- 1. [Depth and texture](#depth-and-texture)- 2. [Shapes](#shapes)- 3. [Gradients and `color-mix()`](#gradients-and-color-mix)- 4. [Patterns](#patterns)-9. [9. Transitions \& animations](#9-transitions--animations)- 1. [Performance](#performance)- 2. [Accessibility](#accessibility)-10. [10. Generated content](#10-generated-content)+# CSS: Modern Architecture++These guidelines provide a high-density reference for writing maintainable and standard-compliant CSS.++- [1. Foundations](#1-foundations)+- [2. Inheritance and The Cascade](#2-inheritance-and-the-cascade)+- [3. Selectors and scoping](#3-selectors-and-scoping)+ - [Prefer CSS selectors over JS for complex element targeting](#prefer-css-selectors-over-js-for-complex-element-targeting)+ - [Use `:is()` (or `:where()`) instead of CSS rule duplication for fallbacks](#use-is-or-where-instead-of-css-rule-duplication-for-fallbacks)+ - [Avoid overmatching](#avoid-overmatching)+ - [Use `:not()` instead of overrides to exclude irrelevant states/targets](#use-not-instead-of-overrides-to-exclude-irrelevant-statestargets)+ - [Prefer `@scope` over `:not()` for excluding (potentially deeply nested) subtrees](#prefer-scope-over-not-for-excluding-potentially-deeply-nested-subtrees)+ - [Overrides are fine for specialization](#overrides-are-fine-for-specialization)+ - [No global resets](#no-global-resets)+ - [Nesting and scoping](#nesting-and-scoping)+- [4. Interactivity](#4-interactivity)+- [5. Design Tokens and Theming](#5-design-tokens-and-theming)+ - [Theming](#theming)+- [6. Responsive design](#6-responsive-design)+- [7. Typography](#7-typography)+- [8. Visual effects](#8-visual-effects)+- [9. Shapes](#9-shapes)+- [10. Transitions \& animations](#10-transitions--animations)+- [11. Generated content](#11-generated-content)## 1. Foundations@@ -144,6 +136,9 @@ button:disabled {This works regardless of reordering, as the first rule does not overmatch.+If you _must_ use an override (e.g. you are using an experimental container query and the `not` case is also the fallback), in some cases you may be able to use the `revert-layer` keyword to remove the value without coupling the override to specific values.+Note that this can only work if the value to fall back to is also layered.+#### Prefer `@scope` over `:not()` for excluding (potentially deeply nested) subtreesWhile `:not()` + descendant selectors can exclude subtrees, this works poorly for deeply nested structures.@@ -205,18 +200,7 @@ Using `@scope` fixes this:## 4. Interactivity-### Focus management--- Use `:focus-visible` to define custom focus rings, not `:focus`.-- Do not remove the browser's default focus rings (via `outline: none`) without providing an alternative visible focus style.-- Prefer `outline` over other properties (e.g. `box-shadow`) for focus rings. If you must rely on `box-shadow` for focus rings, provide an `outline`-based fallback for High Contrast Mode using the `forced-colors` media query.-- Pair focus outlines with `outline-offset` to visually separate the ring from the element.--### Touch targets--- Interactive elements should be at least 24×24 CSS pixels (WCAG 2.5.8 AA). Enforce with `min-block-size` / `min-inline-size` or padding rather than `width` / `height`, so content can grow the target but not shrink it.-- Bump targets up on coarse pointers: `@media (pointer: coarse) { ... }`.-- **DON'T** use `touch-action: none` for custom gestures — it disables page scrolling through the element. Scope to the axis you actually need: `pan-y` for horizontal swipes (page still scrolls vertically), `pan-x` for vertical ones. Reserve `none` for elements where no native touch behavior makes sense (e.g. a drawing canvas).+See `accessibility` (via `npx -y modern-web-guidance@latest retrieve "accessibility"`) for focus rings, touch targets, and custom gestures.## 5. Design Tokens and Theming@@ -233,295 +217,34 @@ Typically these are organized in tiers, with each tier building upon the previouThe smaller the scope of the use case, the fewer tiers it needs. E.g. a quick demo or toy app are fine with one tier. Do not overengineer.Check for any existing conventions around naming and levels before inventing your own.-### Dark mode--- Use `color-scheme: light dark` on `:root` to enable dark mode support that automatically adapts to the system setting. You can also specify `color-scheme` on individual elements to force a different value for that subtree (`light`/`dark` or `light dark` for the system default)-- Use `light-dark()` to provide alternatives that automatically resolve based on the element's `color-scheme`.-Typically this happens in Tier 2 or Tier 3 tokens.-- IMPORTANT: When using `light-dark()` on an inherited `<color>` property, it will resolve to a specific color based on that element's `color-scheme` and inherit as that resolved color, not as a `light-dark()` value. It will NOT adapt to any descendant-specific `color-scheme` overrides. To keep `light-dark()` color tokens dynamic resolve them as late as possible by only passing them around as unregistered custom properties and avoid relying on inherited color values across `color-scheme` boundaries.--See `dark-mode` (via `npx -y modern-web-guidance@latest retrieve "dark-mode"`) for tips & best practices on supporting dark mode switching and `component-specific-light-dark-theme` (via `npx -y modern-web-guidance@latest retrieve "component-specific-light-dark-theme"`) for more on applying different `color-scheme` modes than the page-wide setting on certain elements.--### Forced Colors Mode--In Forced Colors Mode (High Contrast on Windows), the browser overrides author colors with system keywords and strips `background-image`, `box-shadow`, and `border-image`.--- Define system color fallbacks for color tokens using `@media (forced-colors: active)`.-- **DON'T** rely on `background-image`, `box-shadow`, or `border-image` to convey borders, separators, or state — they disappear in forced colors (and often in print too). If you must, ensure there's an alternative in forced colors mode, such as `outline` or `border` with system color keywords (`CanvasText`, `LinkText`, `ButtonText`, `Highlight`, `GrayText`, etc.).-- Use `forced-color-adjust: none` where color is essential information (syntax highlighter, color picker swatch). **DON'T** use `forced-color-adjust: none` just to preserve aesthetics.---### Generating tints--Before generating tints dynamically, check if you can use an existing, predefined, design token. This allows much more designer control and ensures consistency.--If you need to generate lighter or darker colors dynamically:-- **DO NOT** just adjust the lightness channel in `oklch`/`oklab` or `lch`/`lab`, e.g. `oklab(from var(--primary) 0.9 a b)`. While that is theoretically the correct way, browsers do not yet implement gamut mapping, so the resulting color is unpredictable.-- You can use `color-mix()` to mix with white or black (preferably in `oklab`). This keeps the color safely in gamut, but tends to over-desaturate colors and produce washed out tints and shades.-- You MAY combine lightness adjustment with any of the other methods (e.g. `color-mix(in oklab, oklch(from var(--primary) 0.9 c h), white 30%)`) for a balance between the two, but avoid going above 30% for the lightness adjustment.--### Theming browser-generated UI+### Theming-Most browser-generated UI can be customized to some extent using CSS.-Even if it requires modern features, it degrades gracefully in older browsers, and thus often does not require a polyfill or fallback.--Before re-creating browser UI (form controls, scrollbars, selections, error messages, etc), first verify that:-1. the browser UI cannot be customized enough for your needs, even with modern CSS,-2. the desired customization is sufficiently critical to justify the tradeoffs of re-creating built-in UI — most notably losing accessible semantics, keyboard handling, IME, and AT integration that the native UI provides for free.--Example customizations that are possible:-- Use `::selection` to customize highlighted text colors.-- **DON'T** apply `user-select: none` to content text — breaks copy-paste, translation tools, and AT "read from here" gestures. Limit it to chrome (drag handles, toolbars, redundant button labels).-- Use `accent-color` to apply the page's accent color to any browser-generated UI.-- Use `color-scheme` to have browser UI adapt to light/dark mode.-- Use `scrollbar-color` to customize scrollbar colors and `scrollbar-width` to control scrollbar thickness — keep the thumb visibly distinct from the track (≥3:1), and don't set `scrollbar-width: none` on scrollable regions (use it only when scrolling is fully replaced by another affordance).-- Use `:user-invalid` / `:user-valid` for validity styling, **not** `:invalid` / `:valid` — they only match after the user has interacted with the field, avoiding the hostile default of flagging required-empty fields as errors on page load.-- Buttons and text fields (including `<textarea>`) can generally be styled as normal elements.-- Use `font-size` to scale and other textual properties to control typography--#### Styling textual fields (`<input>` & `<textarea>`)--For most styling purposes (e.g. colors, borders, backgrounds, typography, etc) treat these elements as normal text containers.--- Use `:placeholder-shown` and `::placeholder` to style input placeholders.-- Use `field-sizing: content` to make text fields size to content.-- For `<textarea>` elements, use `resize: vertical` to disable horizontal resizing or `resize: none` to disable all resizing.--#### Multiple choice controls (select, radios, checkboxes)--- To select one among many options presented in a dropdown: Use a `<select>` + `appearance: base-select` + `::picker(select)`. For more info see `branded-select-styling` (via `npx -y modern-web-guidance@latest retrieve "branded-select-styling"`)-- Selecting one or more among multiple options laid out inline in the page: Use a `<input type=checkbox>` or `<input type=radio>` inside a `<label>` for each option. Style via `label:has(:checked)`.-- Style checkboxes, radios and switches via `appearance: none` + generated content (`::before`/`::after`) or background images to draw the checked state.-<!-- Customizable select listbox version currently buggy + this has much better browser support -->--#### Non-textual `<input>`s (buttons, sliders, file inputs etc.)--- File inputs: Use `::file-selector-button` to style the button.-- Do not use `<input>` with a `type` of `button`, `submit` or `reset`. Use `<button>` instead and style it as a regular element.-- Sliders: Use `appearance: none` + thumb pseudo-elements (`::-webkit-slider-thumb`, `::-moz-range-thumb`, etc) and track pseudo-elements (`::-webkit-slider-runnable-track`, `::-moz-range-track`, etc) for more granular control.+- Dark mode: see `dark-mode` (via `npx -y modern-web-guidance@latest retrieve "dark-mode"`) and `component-specific-light-dark-theme` (via `npx -y modern-web-guidance@latest retrieve "component-specific-light-dark-theme"`).+- Forced Colors Mode: see `color` (via `npx -y modern-web-guidance@latest retrieve "color"`).+- Generating tints and shades: see `color` (via `npx -y modern-web-guidance@latest retrieve "color"`).+- Theming browser-generated UI (selection, scrollbars, form controls): see `browser-ui-theming` (via `npx -y modern-web-guidance@latest retrieve "browser-ui-theming"`).## 6. Responsive design-- Use `@container` queries to create component-driven responsive layouts that adapt to their parent container's size rather than the viewport.-- Use dynamic viewport units (`dvh`, `dvw`) instead of `vh`/`vw` to prevent layout breakage when mobile browser UI elements (like address bars) appear or disappear.-- Use `aspect-ratio` for media elements (like `<img>` and `<video>`) to reserve space during loading and prevent Cumulative Layout Shift (CLS).--### Responsive Typography--- **DO** combine viewport-relative and font-relative units in `clamp()` for font sizes that scale with the viewport size while ensuring they stay within a desired range. For example, `clamp(2rem, 1rem + 5vw, 4rem)`. Adjust the proportion of viewport-relative and font-relative units to control how quickly the font-size changes.-- **DON'T** use `vw` alone for font-size without `clamp()`, as it can scale text too small or too large on extreme screens.+See `responsive-design` (via `npx -y modern-web-guidance@latest retrieve "responsive-design"`) for components that adapt to the space they are given, layouts that survive mobile browser UI appearing and disappearing, reserving space for media before it loads, and text that scales with the viewport.## 7. Typography-- Use unitless numbers for `line-height` (e.g., `1.5`) to ensure relative scaling during font-size inheritance.-- Use `overflow-wrap: break-word` (or `anywhere`) to contain long URLs.-- **DON'T** use `px` for font-size. Prefer `rem` to honor the user's browser font-size preferences (root font size), or `em` for contextual sizing.--### Text wrapping--- Use `text-wrap: balance` for balanced headlines and headline-like content (e.g. `<th>`)-- Use `text-wrap: pretty` for long-form body text (paragraphs, blockquotes, etc.)-- Use `text-wrap: balance` or `text-wrap: pretty` deliberately, **DO NOT** apply it on `*` as it does have a performance cost.-- Avoid `text-wrap: balance` on elements with a visible box (backgrounds, borders, shadows, etc) as it does not change the container's width, it only affects how text wraps *within* that width. This can leave empty space at the end of the container, which is usually undesirable.+See `typography` (via `npx -y modern-web-guidance@latest retrieve "typography"`) for guidelines around readability, accessibility, and aesthetics of text on Web UIs.## 8. Visual effects-### Depth and texture+See `visual-effects` (via `npx -y modern-web-guidance@latest retrieve "visual-effects"`) for look & feel enhancements such as conveying depth, texture, and elevation, blending layers, aesthetically pleasing gradients, and flexible pattern backgrounds.-- Layer multiple shadows for realistic soft depth effects.-- Use `filter: drop-shadow()` instead of `box-shadow` for non-rectangular shapes or transparent PNGs.-- Use `mix-blend-mode` and `background-blend-mode` for lighting overlays (limit scope with `isolation: isolate`)--```css-.hero {- background-image: url('texture.png'), linear-gradient(to bottom, #fff, #eee);- background-blend-mode: soft-light;-}-```--### Shapes+## 9. Shapes- Use `corner-shape: squircle` for more aesthetically pleasing curves as a progressive enhancement over regular rounded corners.- Use elliptical `border-radius` (e.g., `10px / 20px`) for proportional curves without extra elements.-### Gradients and `color-mix()`--Use `in oklch` or `in oklab` to explicitly specify the interpolation color space for gradients or `color-mix()`.-- `in oklch` preserves chroma better, but can more easily get out of device gamut, especially for bigger differences between colors-- `in oklab` stays in gamut more easily (assuming in-gamut endpoints) but can create washed out desaturated colors in the middle, especially when interpolating between opposite hues.-- *DON'T* use `in srgb` unless you have a specific reason to do so (e.g. you are building a color picker that needs to interpolate in srgb).--#### Fallback--Some pre-2024 browsers do not support gradient color interpolation space.-To support these browsers, use the token only when its usage is safe by defining a variable:--```css-:root {- --in-oklab: ;- --in-oklch: ;-}--@supports (linear-gradient(in oklab, white, black)) {- :root {- --in-oklab: in oklab;- --in-oklch: in oklch;- }-}-```--Then use like:--```css-.card {- background: linear-gradient(to bottom var(--in-oklab), var(--accent-color), var(--darker));-}-```--- **Important:** If you use this technique, make sure there is always a non-empty gradient preamble without it, otherwise it will be a syntax error in older browsers.-- You do NOT need this for `color-mix()`. If a browser supports `color-mix()`, it also supports its `in <color-space>` argument.--### Patterns--Many patterns can be created via CSS gradients + hard stops, and these can be more flexible and performant than SVGs or external images as they can have access to CSS variables and lengths from the surrounding context.-You don't need to repeat the position twice — just use `0` or `0%` and gradient fixup will auto-adjust it.--Examples below.--Vertical stripes of `1em` width each:--```css-background: linear-gradient(to right, var(--color-1) 50%, var(--color-2) 0) 0 / 2em;-```--Diagonal stripes of `1em` width each:--```css-background: repeating-linear-gradient(-45deg, var(--color-1) 0 1em, var(--color-2) 0 2em);-```--Checkerboard pattern with `1em` squares:--```css-background: repeating-conic-gradient(var(--color-1) 0 25%, var(--color-2) 0 50%) 0 / 2em 2em;-```--Polka dot with `.5em` radius dots spaced `2em` apart (horizontally/vertically — multiply by `sqrt(2)` for diagonal distance):--```css---distance: 2em;---radius: .5em;---polka: radial-gradient(circle, var(--color-1) var(--radius), transparent calc(var(--radius) + 1px));-background: var(--polka) 0 0, var(--polka) var(--distance) var(--distance) var(--color-2);-background-size: calc(var(--distance) * 2) calc(var(--distance) * 2);-```--Simple pie chart:--```css-.pie {- --p: 80%;- width: 60px;- aspect-ratio: 1;- border-radius: 50%;- background: conic-gradient(var(--color-1) var(--p), transparent 0%) var(--color-2);-}-```--**Important:** When using gradients to render charts, ensure there is a textual fallback for screen readers. MANDATORY: You MUST provide a semantic data table as an accessible alternative, as detailed in `accessibility` (via `npx -y modern-web-guidance@latest retrieve "accessibility"`) under the alternate text and media guidelines.--## 9. Transitions & animations--- Use `clip-path` and `mask-image` for custom geometric reveals and smooth fade-outs.-- Use **Scroll-Driven Animations** (`animation-timeline: scroll()`) for non-essential scroll-bound effects instead of JS listeners.-- Use **View Transitions** to animate between complex layout states seamlessly.--### Performance--Rendering performance is critical for smooth user experiences, especially in heavy DOM trees.--- Prefer to animate `opacity` and `transform` (including individual transform properties, e.g. `translate` instead of `left/right/top/bottom`) to ensure animations stay on the compositor thread.-- Use `transition-behavior: allow-discrete` + `@starting-style` to animate layout properties like `display` or `<dialog>` state natively.-- Always pair `content-visibility` with `contain-intrinsic-size` to prevent scrollbar jumps (CLS).-- When setting `contain-intrinsic-size` use the `auto` keyword and a value that’s derived from what is known about the contents (i.e. text size, spacing, size of graphics, character count). Preferably use units such as `rem`, `lh`, `cap`, or `ch` that match values used for the elements within the contents rather than `px`. If the content for items in a group is not consistently sized, then use an average size.-- Use `contain: layout style paint` to isolate component rendering updates.--#### Code Example: Render Optimization--```css-.large-section {- content-visibility: auto;- contain-intrinsic-block-size: auto 800px;-}--.row {- --row-gap: .4rem;- --title-height: 1lh;- --description-height: 0.85lh;-- display: grid;- row-gap: var(--row-gap);- content-visibility: auto;- /* The sum of the title height, row gap, and description height should be the size of the contents when skipped for rendering. */- contain-intrinsic-block-size: auto calc(var(--title-height) + var(--row-gap) + var(--description-height));-}--.popover-reveal {- /* Allow discrete animations for display transitions */- transition: display 0.2s allow-discrete;-}-```--### Accessibility+## 10. Transitions & animations-Use `prefers-reduced-motion` media queries to turn off heavy motion for users who prefer it.--**DO NOT** globally apply `animation-duration: 0.01ms;` globally as it can cause certain animations to become _more_ jarring.-Either apply reduced motion versions on a case by case basis, or use a custom property like:--```css-@property --animation-reduced {- syntax: "*";- inherits: false;- initial-value: none;-}--@media (prefers-reduced-motion: reduce) {- * {- animation: var(--animation-reduced) !important;- }-}-```+See `motion` (via `npx -y modern-web-guidance@latest retrieve "motion"`). For rendering performance (`content-visibility`, containment), see `performance` (via `npx -y modern-web-guidance@latest retrieve "performance"`).-Then, reduced motion versions can be kept together with the original animations:--```css-progress:not([value]) {- animation: slide 1s infinite linear;- --animation-reduced: slide 20s infinite linear;-}-```--## 10. Generated content--- **DON'T** use `content` to convey meaningful text (labels, state, instructions) — keep that in the DOM (WCAG F87). The alt text argument is harm reduction for cases where decoration accidentally carries meaning, not a license.-- Use the alternative text argument of `content` to provide alt text for screen readers. E.g. `content: url(cloud.svg) / "Save";`-- Use `content: "text" / "";` to prevent purely decorative text from being announced to screen readers.-- **DON'T** use an empty alt text argument for images — they're already presentational by default. E.g. this is wrong: `content: url(cloud.svg) / "";`.-- **DON'T** use the alt text argument to describe emojis unless the description differs from the official emoji name. E.g. don't do `content: "🎉" / "celebration";`, but `content: "🎉" / "Yay!";` is fine.--**ONLY** use the alt text argument when the text is different than the primary value and is not already present in the DOM. I.e. this is wrong:--HTML:-```html-<button class="save">Save</button>-```--CSS:-```css-button.save::before {- content: url(cloud.svg) / "Save";-}-```+## 11. Generated content+See `accessible-generated-content` (via `npx -y modern-web-guidance@latest retrieve "accessible-generated-content"`) for adding decorative or supplementary content with CSS without breaking screen readers or copy-paste.-A screen reader would read it out as "Save save".diff --git a/skills/modern-web-guidance/guides/css/overflow-clipping-control.md b/skills/modern-web-guidance/guides/css/overflow-clipping-control.mdindex 5e0f143..6c11914 100644--- a/skills/modern-web-guidance/guides/css/overflow-clipping-control.md+++ b/skills/modern-web-guidance/guides/css/overflow-clipping-control.md@@ -108,7 +108,7 @@ The following examples demonstrate dynamic container layout controls, showcasingBaseline status for overflow: clip: Widely available. It's been Baseline since 2022-09-12.Supported by: Chrome 90 (Apr 2021), Edge 90 (Apr 2021), Firefox 81 (Sep 2020), and Safari 16 (Sep 2022).-overflow-clip-margin has limited availability.+Browser support for overflow-clip-margin: Limited availability.Supported by: Firefox 148 (Feb 2026).Unsupported in: Chrome, Edge, and Safari.diff --git a/skills/modern-web-guidance/guides/css/reduce-style-repetition.md b/skills/modern-web-guidance/guides/css/reduce-style-repetition.mdindex 05943bb..4c8246d 100644--- a/skills/modern-web-guidance/guides/css/reduce-style-repetition.md+++ b/skills/modern-web-guidance/guides/css/reduce-style-repetition.md@@ -64,7 +64,7 @@ main {### Fallback strategies-@function has limited availability.+Browser support for @function: Limited availability.Supported by: Chrome 139 (Aug 2025) and Edge 139 (Aug 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/css/responsive-design.md b/skills/modern-web-guidance/guides/css/responsive-design.mdnew file mode 100644index 0000000..5ea79aa--- /dev/null+++ b/skills/modern-web-guidance/guides/css/responsive-design.md@@ -0,0 +1,16 @@+# Responsive design++## Overall best practices++- Use `@container` queries to create component-driven responsive layouts that adapt to their parent container's size rather than the viewport. See `size-aware-styling` (via `npx -y modern-web-guidance@latest retrieve "size-aware-styling"`) for more details.+- Use dynamic viewport units (`dvh`, `dvw`) instead of `vh`/`vw` to prevent layout breakage when mobile browser UI elements (like address bars) appear or disappear.+- Use `aspect-ratio` for media elements (like `<img>` and `<video>`) to reserve space during loading and prevent Cumulative Layout Shift (CLS).++For the layout mechanics behind responsive UI (flexbox, grid, container query units, viewport units), see `css-layout` (via `npx -y modern-web-guidance@latest retrieve "css-layout"`).++## Responsive typography++- **DO** combine viewport-relative and font-relative units in `clamp()` for font sizes that scale with the viewport size while ensuring they stay within a desired range. For example, `clamp(2rem, 1rem + 5vw, 4rem)`. Adjust the proportion of viewport-relative and font-relative units to control how quickly the font-size changes.+- **DON'T** use `vw` alone for font-size without `clamp()`, as it can scale text too small or too large on extreme screens.++To scale type and spacing with the container instead of the viewport, see `fluid-scaling` (via `npx -y modern-web-guidance@latest retrieve "fluid-scaling"`).diff --git a/skills/modern-web-guidance/guides/css/selector-atrule-combinations.md b/skills/modern-web-guidance/guides/css/selector-atrule-combinations.mdnew file mode 100644index 0000000..c6002f5--- /dev/null+++ b/skills/modern-web-guidance/guides/css/selector-atrule-combinations.md@@ -0,0 +1,150 @@+# Selector & @-rule Combinations++## The problem++We often need to combine filtering criteria of different types, e.g. selectors + media queries, media queries + container queries, and so on.++For example, combining `(prefers-color-scheme: dark)` with a selector that targets color scheme overrides (e.g. `:root:has(> head > meta[name="color-scheme"][content="dark"])` or `:root.dark`) to apply certain styles in light/dark mode regardless of how the color scheme was set.++The naive approach leads to duplicated code:++```css+/* Light mode styles */+.card.featured {+ font-weight: 400;+}++#logo-dark {+ display: none;+}++@media (prefers-color-scheme: dark) {+ /* Dark mode styles */+ :root:not(.light) {+ .card.featured {+ font-weight: 300;+ }++ #logo-dark {+ display: inline;+ }++ #logo {+ display: none;+ }+ }+}++/* Dark mode styles, again */+:root.dark {+ .card.featured {+ font-weight: 300;+ }++ #logo-dark {+ display: inline;+ }++ #logo {+ display: none;+ }+}+```++## What to do instead++Store the result of the combined filter on a custom property, then use container style queries to set rules based on that property.++IMPORTANT: Due to how container queries work, this technique only works if we can set the custom property on an ancestor of any rules that must be matched.++### 1. Decouple selection logic from applied rules++```css+:root {+ --color-scheme: light;++ @media (prefers-color-scheme: dark) {+ --color-scheme: dark;+ }++ &:has(> head > meta[name="color-scheme"][content="dark"]) {+ --color-scheme: dark;+ }++ &:has(> head > meta[name="color-scheme"][content="light"]) {+ --color-scheme: light;+ }+}+```++### 2. Key on the custom property for applied rules++```css+@container not style(--color-scheme: dark) {+ .card.featured {+ font-weight: 400;+ }++ #logo-dark {+ display: none;+ }+}++@container style(--color-scheme: dark) {+ .card.featured {+ font-weight: 300;+ }++ #logo {+ display: none;+ }+}+```++### 3. OPTIONAL: Utility classes for toggling visibility++A very common case is toggling visibility based on whether the criteria match.+Utility classes must win over arbitrary component styles (hence `!important`) and their shown `display` is unknown, so they can't use overrides — gate them with `not style(...)`:++```css+@container not style(--color-scheme: dark) {+ .if-dark {+ display: none !important;+ }+}++@container not style(--color-scheme: light) {+ .if-light {+ display: none !important;+ }+}+```++## Fallbacks++Baseline status for Container style queries: Newly available. It's been Baseline since 2026-05-19.+Supported by: Chrome 111 (Mar 2023), Edge 111 (Mar 2023), Firefox 151 (May 2026), and Safari 18 (Sep 2024).++There are two types of fallbacks, depending on how critical the branching is and what constitutes an acceptable fallback.++1. For critical branching, where all states must work correctly even if style queries are not supported, you simply cannot use style queries.+Instead, use the naive approach above, duplicating rules for each state.+Utility classes can still be used, as long as they are also defined that way.+2. For non-critical branching, where a default state is acceptable, you can define the base styles outside of any `@container` rule, and only use style queries as overrides.+This preserves most of the spirit of this approach, its main downside being the coupling of values that overrides introduce.++```css+#logo-dark {+ display: none;+}++@container style(--color-scheme: dark) {+ #logo-dark {+ display: inline; /* override */+ }++ #logo {+ display: none;+ }+}+```diff --git a/skills/modern-web-guidance/guides/forms/animated-select-picker.md b/skills/modern-web-guidance/guides/forms/animated-select-picker.mdindex b7ccd76..20d3fab 100644--- a/skills/modern-web-guidance/guides/forms/animated-select-picker.md+++ b/skills/modern-web-guidance/guides/forms/animated-select-picker.md@@ -159,7 +159,7 @@ The following example demonstrates a custom select styled with standard page ani### Fallbacks & browser support for Customizable <select>-Customizable <select> has limited availability.+Browser support for Customizable <select>: Limited availability.Supported by: Chrome 135 (Apr 2025), Edge 135 (Apr 2025), and Safari 27.Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/forms/autofill-address-form.md b/skills/modern-web-guidance/guides/forms/autofill-address-form.mdindex 70163f9..e44a86f 100644--- a/skills/modern-web-guidance/guides/forms/autofill-address-form.md+++ b/skills/modern-web-guidance/guides/forms/autofill-address-form.md@@ -68,7 +68,7 @@ Add the `required` attribute to mandatory fields.### Fallback strategies-:autofill has limited availability.+Browser support for :autofill: Limited availability.Supported by: Chrome 110 (Feb 2023), Edge 110 (Feb 2023), and Safari 15 (Sep 2021).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/forms/autofill-highlight-inputs.md b/skills/modern-web-guidance/guides/forms/autofill-highlight-inputs.mdindex 538909d..586192e 100644--- a/skills/modern-web-guidance/guides/forms/autofill-highlight-inputs.md+++ b/skills/modern-web-guidance/guides/forms/autofill-highlight-inputs.md@@ -38,7 +38,7 @@ MANDATORY: Use `:autofill` as this is the correct pseudo-class name.### Fallback strategies-:autofill has limited availability.+Browser support for :autofill: Limited availability.Supported by: Chrome 110 (Feb 2023), Edge 110 (Feb 2023), and Safari 15 (Sep 2021).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/forms/autofill-sign-in-form.md b/skills/modern-web-guidance/guides/forms/autofill-sign-in-form.mdindex 1740bce..e10a5ec 100644--- a/skills/modern-web-guidance/guides/forms/autofill-sign-in-form.md+++ b/skills/modern-web-guidance/guides/forms/autofill-sign-in-form.md@@ -29,6 +29,8 @@ Always use `type="email"` for email addresses and `type="tel"` for phone numbersEvery `<input>`, `<select>`, and `<textarea>` element SHOULD have an appropriate `autocomplete` attribute, to improve accessibility and help users avoid re-entering data.+Username and email inputs hold identifiers, not prose. Add `spellcheck="false"` so the browser does not rewrite them into something the account does not match. `autocorrect` and `autocapitalize` are always disabled for `input type="email"`, but are required for non-email usernames.+### Make buttons helpfulUse `<button>` for buttons. You can also use `<input type="submit">`, but don't use a `div` or some other random element acting as a button. Button elements provide accessible behaviour, built-in form submission functionality, and can easily be styled.@@ -133,4 +135,7 @@ Supported by: Chrome 5 (May 2010), Edge 12 (Jul 2015), Firefox 4 (Mar 2011), SafBaseline status for inputmode: Widely available. It's been Baseline since 2021-12-07.Supported by: Chrome 66 (Apr 2018), Edge 79 (Jan 2020), Firefox 95 (Dec 2021), Safari 12.1 (Mar 2019), and Safari iOS 12.2 (Mar 2019).+Baseline status for autocorrect: Newly available. It's been Baseline since 2026-09-11.+Supported by: Chrome 153, Edge 153, Firefox 136 (Mar 2025), Safari 14.1 (Apr 2021), and Safari iOS 14.5 (Apr 2021).+Autofill is a progressive enhancement. In browsers that do not support autofill, users will simply need to manually enter their sign-in credentials. The semantic HTML constraints (such as `type`, `inputmode`, and `required`) will still function appropriately to validate user input and provide the correct virtual keyboards.diff --git a/skills/modern-web-guidance/guides/forms/autofill-sign-up-form.md b/skills/modern-web-guidance/guides/forms/autofill-sign-up-form.mdindex 896ff24..e25c9a9 100644--- a/skills/modern-web-guidance/guides/forms/autofill-sign-up-form.md+++ b/skills/modern-web-guidance/guides/forms/autofill-sign-up-form.md@@ -29,6 +29,8 @@ Always use `type="email"` for email addresses and `type="tel"` for phone numbersEvery `<input>`, `<select>`, and `<textarea>` element SHOULD have an appropriate `autocomplete` attribute, to improve accessibility and help users avoid re-entering data.+Username and email inputs hold identifiers, not prose. Add `spellcheck="false"` so the browser does not rewrite them into something the account does not match. `autocorrect` and `autocapitalize` are always disabled for `input type="email"`, but are required for non-email usernames.+### Make buttons helpfulUse `<button>` for buttons. You can also use `<input type="submit">`, but don't use a `div` or some other random element acting as a button. Button elements provide accessible behaviour, built-in form submission functionality, and can easily be styled.@@ -143,4 +145,7 @@ Supported by: Chrome 5 (May 2010), Edge 12 (Jul 2015), Firefox 4 (Mar 2011), SafBaseline status for inputmode: Widely available. It's been Baseline since 2021-12-07.Supported by: Chrome 66 (Apr 2018), Edge 79 (Jan 2020), Firefox 95 (Dec 2021), Safari 12.1 (Mar 2019), and Safari iOS 12.2 (Mar 2019).+Baseline status for autocorrect: Newly available. It's been Baseline since 2026-09-11.+Supported by: Chrome 153, Edge 153, Firefox 136 (Mar 2025), Safari 14.1 (Apr 2021), and Safari iOS 14.5 (Apr 2021).+Autofill is a progressive enhancement. In browsers that do not support autofill, users will simply need to manually enter their sign-up credentials. The semantic HTML constraints (such as `type`, `inputmode`, and `required`) will still function appropriately to validate user input and provide the correct virtual keyboards.diff --git a/skills/modern-web-guidance/guides/forms/brand-consistent-forms.md b/skills/modern-web-guidance/guides/forms/brand-consistent-forms.mdindex 912c2ef..acec222 100644--- a/skills/modern-web-guidance/guides/forms/brand-consistent-forms.md+++ b/skills/modern-web-guidance/guides/forms/brand-consistent-forms.md@@ -70,7 +70,7 @@ body {## Fallback Strategy-accent-color has limited availability.+Browser support for accent-color: Limited availability.Supported by: Chrome 93 (Aug 2021), Edge 93 (Sep 2021), Firefox 92 (Sep 2021), and Safari 26.2 (Dec 2025).For browsers that do not support `accent-color`, the form controls fall back to the browser's default appearance. To ensure full brand consistency and high reliability across all environments, you MUST implement a custom fallback strategy using the established "visually hidden input" technique.diff --git a/skills/modern-web-guidance/guides/forms/branded-select-styling.md b/skills/modern-web-guidance/guides/forms/branded-select-styling.mdindex 8d9bfa9..0e92980 100644--- a/skills/modern-web-guidance/guides/forms/branded-select-styling.md+++ b/skills/modern-web-guidance/guides/forms/branded-select-styling.md@@ -95,7 +95,7 @@ The following example demonstrates a custom select styled with a monospace font### Fallbacks & browser support for Customizable <select>-Customizable <select> has limited availability.+Browser support for Customizable <select>: Limited availability.Supported by: Chrome 135 (Apr 2025), Edge 135 (Apr 2025), and Safari 27.Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/forms/custom-select-picker-layouts.md b/skills/modern-web-guidance/guides/forms/custom-select-picker-layouts.mdindex 744678d..533bb0a 100644--- a/skills/modern-web-guidance/guides/forms/custom-select-picker-layouts.md+++ b/skills/modern-web-guidance/guides/forms/custom-select-picker-layouts.md@@ -146,7 +146,7 @@ Otherwise, it may be ultimately necessary to switch to a custom solution using t### Fallbacks & browser support for Customizable <select>-Customizable <select> has limited availability.+Browser support for Customizable <select>: Limited availability.Supported by: Chrome 135 (Apr 2025), Edge 135 (Apr 2025), and Safari 27.Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/forms/forms.md b/skills/modern-web-guidance/guides/forms/forms.mdindex 0b85b68..0409c17 100644--- a/skills/modern-web-guidance/guides/forms/forms.md+++ b/skills/modern-web-guidance/guides/forms/forms.md@@ -76,22 +76,27 @@</style>```-## 3. Autofill and Input Modes+## 3. Autofill and Input Hints### Guidelines- **DO** use the `autocomplete` attribute to specify expected data (e.g., `email`, `tel`, `current-password`, `new-password`).- **DO** use `inputmode` to optimize on-screen keyboards (e.g., `inputmode="numeric"` for PINs).- **DO** use `enterkeyhint` to set the Enter key label (e.g., `next`, `done`).+- **DO** turn off text correction on fields that hold identifiers rather than prose: `autocorrect="off"` (plus `autocapitalize="off"` and `spellcheck="false"`) on usernames, emails, URLs, codes, and search inputs. Leave the defaults on for free-text fields like messages and comments.- **DO** use single-field inputs for complex numbers (credit cards, phones) to help autofill.+- **DO** use a single `<input type="text" inputmode="numeric" autocomplete="one-time-code">` and the WebOTP API for SMS one-time passcode verification. See guide `sms-otp-form` (via `npx -y modern-web-guidance@latest retrieve "sms-otp-form"`).-- **DON'T** use `type="number"` for credit cards or ZIP codes (causes UI scroll issues and removes leading zeros).+- **DON'T** use `type="number"` for credit cards, ZIP codes, or one-time passcodes (causes UI scroll issues and removes leading zeros).### Code Example```html<label for="zip">ZIP Code:</label><input type="text" id="zip" name="zip" autocomplete="postal-code" inputmode="numeric" pattern="\d{5}">++<label for="username">Username:</label>+<input type="text" id="username" name="username" autocomplete="username" autocorrect="off" autocapitalize="off" spellcheck="false">```## 4. Constraints and Validationdiff --git a/skills/modern-web-guidance/guides/forms/rich-media-picker.md b/skills/modern-web-guidance/guides/forms/rich-media-picker.mdindex 34ca6ec..1a09518 100644--- a/skills/modern-web-guidance/guides/forms/rich-media-picker.md+++ b/skills/modern-web-guidance/guides/forms/rich-media-picker.md@@ -113,7 +113,7 @@ select.custom-select option:checked .option-title {### Fallbacks & browser support for Customizable <select>-Customizable <select> has limited availability.+Browser support for Customizable <select>: Limited availability.Supported by: Chrome 135 (Apr 2025), Edge 135 (Apr 2025), and Safari 27.Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/forms/sms-otp-form.md b/skills/modern-web-guidance/guides/forms/sms-otp-form.mdnew file mode 100644index 0000000..ce745b2--- /dev/null+++ b/skills/modern-web-guidance/guides/forms/sms-otp-form.md@@ -0,0 +1,208 @@+# SMS OTP form verification++Delivering a one-time passcode (OTP) via SMS is a common flow for phone number verification, account recovery, step-up authentication, and payment confirmation. Switching between a browser and an SMS messaging app to memorize or copy-paste a multi-digit code introduces user friction, increases drop-off rates, and leaves users vulnerable to phishing on spoofed domains.++Combining semantic `<form>` markup, `<input autocomplete="one-time-code" inputmode="numeric">`, origin-bound SMS formatting (`@domain #code`), and the WebOTP API (`OTPCredential`) creates a layered, progressively enhanced verification flow:++1. **Automatic extraction and submission**: Browsers supporting the WebOTP API verify the origin against the `@domain #code` line in the SMS, populate the `<input>`, and trigger verification with a single tap.+2. **Origin-bound keyboard autofill**: Browsers and operating systems that support `autocomplete="one-time-code"` (such as Safari on iOS, iPadOS, and macOS) parse the `@domain #code` message and suggest the code in the keyboard autofill bar only when the domain matches.+3. **Frictionless manual entry**: Users entering a code from another device receive a numeric virtual keypad via `inputmode="numeric"` without the usability hazards of `<input type="number">`.++## Security considerations++SMS OTP verifies possession of a phone number and provides convenient step-up verification, but SMS transport and phone numbers can be subject to SIM swapping, number recycling, and interception. Always pair client-side autofill and the WebOTP API with the origin-bound `@domain #code` SMS format so the browser and OS verify that the target domain matches before suggesting or delivering the code. For primary phishing-resistant authentication, prefer passkeys over SMS-based codes (see `passkeys` (via `npx -y modern-web-guidance@latest retrieve "passkeys"`)).++## Semantic form markup++Wrap the verification control in a semantic `<form>` element with `method="POST"` and an explicit `<button type="submit">`. Always use a single `<input>` element rather than splitting digits across multiple boxes.++- **Use `type="text"` with `inputmode="numeric"`**: Never use `type="number"` for OTP codes. A one-time passcode is an identifier string that may contain leading zeros (such as `012345`), not a countable quantity. Using `type="number"` adds increment/decrement spinner buttons, can strip leading zeros, and allows accidental scroll-wheel value changes. Also avoid `type="tel"`, which is a legacy workaround intended for full telephone numbers. Pair `type="text"` with `inputmode="numeric"` to present a digits-only virtual keyboard on mobile devices.+- **Add `autocomplete="one-time-code"`**: Instructs browsers and operating systems to suggest incoming SMS verification codes in the autofill bar when the `<input>` is focused.+- **Place instructional hints above the `<input>`**: Associate a visible `<label>` using `for` and `id`, and place any format instructions (linked via `aria-describedby`) visually **above** the `<input>` so autofill popovers and mobile virtual keyboards never cover the instructions.+- **Do not split digits across multiple `<input>` elements**: Multi-box OTP patterns (six separate `maxlength="1"` inputs) break native `autocomplete="one-time-code"` autofill in many browsers, hinder copy-pasting, and complicate screen reader navigation. If a segmented visual design is required, style a single `<input>` with `letter-spacing` and a monospace font.++```html+<form id="otp-form" action="/verify-otp" method="POST">+ <div class="form-group">+ <label for="otp-input">Verification code</label>+ <!-- Place the hint above the input so autofill popovers and mobile keyboards do not obscure it -->+ <p id="otp-format-hint" class="field-hint">+ Enter the 6-digit code sent to your phone.+ </p>+ <!-- MANDATORY: Use a single input with type="text", inputmode="numeric", and autocomplete="one-time-code" -->+ <input+ type="text"+ id="otp-input"+ name="otp"+ inputmode="numeric"+ autocomplete="one-time-code"+ pattern="\d{6}"+ maxlength="6"+ aria-describedby="otp-format-hint"+ required>+ </div>+ <button type="submit">Verify code</button>+</form>+```++```css+/* Optional: Style a single input to visually space digits without splitting the DOM element */+#otp-input {+ font-family: ui-monospace, monospace;+ font-size: 1.25rem; /* Example value: must be at least 1rem (16px) to prevent mobile browser auto-zoom */+ letter-spacing: 0.35em;+ min-height: 48px;+ padding: 0.5rem 0.75rem;+ box-sizing: border-box;+}+```++## Origin-bound SMS message format++For both the WebOTP API and Safari's domain-bound `autocomplete="one-time-code"` autofill to verify that the code belongs to your website, your backend SMS service must format the **last line** of the text message with the origin domain prefixed by `@` and the OTP prefixed by `#`:++```text+Your verification code is 123456.+[email protected] #123456+```++Enforce the following formatting rules on the outgoing SMS message:++- **Include human-readable text first**: Always start the SMS with a clear human-readable sentence containing the code so users typing it manually on another device can read it easily.+- **Place `@<domain> #<otp>` on the very last line**: The `@` character must be the first character of the final line, with no trailing lines or signature text after it.+- **Use only the host domain**: Do not include a URL scheme (`https://` or `http://`), port (`:8080`), or path (`/verify`) in the `@domain` token.+- **Separate tokens with a single space**: Place exactly one space between `@<domain>` and `#<otp>`, and never include whitespace inside the domain or between `#` and the code.++## Integrating the WebOTP API into your verification flow++The WebOTP API (`OTPCredential`) requires a Secure Context (`https://` in production, or `http://localhost` during local development). Instead of pasting a disconnected `DOMContentLoaded` script that queries the DOM and calls `form.submit()`, integrate `navigator.credentials.get()` directly into the lifecycle and submission handler of your verification UI:++- **Tie the request lifecycle to the active OTP step**: Start listening for the OTP when the verification input is rendered and active (for example, when the OTP step mounts after the user requests an SMS code, and again whenever the user clicks a "Resend code" button).+- **Manage an `AbortController` across all exit paths**: Pass an `AbortSignal` (`signal: ac.signal`) to `navigator.credentials.get()`. Call `ac.abort()` whenever:+ - The user manually submits the form (or submits a code filled via `autocomplete="one-time-code"`).+ - A new SMS code is requested ("Resend code"), aborting the previous controller before creating a new one.+ - The verification component, dialog, or route unmounts.+- **Trigger the application's submission handler (`form.requestSubmit()`)**: When `navigator.credentials.get()` resolves with `otp`, set `otpInput.value = otp.code` and call `form.requestSubmit()` (or invoke your verification function directly). Do **NOT** call `form.submit()`, because `form.submit()` bypasses `submit` event listeners (`event.preventDefault()` / `fetch()` handlers) and skips native constraint validation.++```javascript+const otpForm = document.getElementById('otp-form');+const otpInput = document.getElementById('otp-input');++let otpAbortController = null;++function stopSmsOtpListener() {+ if (otpAbortController) {+ otpAbortController.abort();+ otpAbortController = null;+ }+}++async function startSmsOtpListener() {+ // Feature-detect WebOTP support+ if (!otpInput || !('OTPCredential' in window)) {+ return;+ }++ // Cancel any previous pending WebOTP request (e.g., when re-sending an SMS code)+ stopSmsOtpListener();+ const ac = new AbortController();+ otpAbortController = ac;++ try {+ const otp = await navigator.credentials.get({+ otp: { transport: ['sms'] },+ signal: ac.signal,+ });++ if (!otp) return;+ otpInput.value = otp.code;++ // Trigger standard form submission so submit event listeners and validation run+ if (otpForm) {+ otpForm.requestSubmit();+ }+ } catch (err) {+ // Expected when aborted by manual submission, resend, unmount, or user dismissal+ if (err && err.name === 'AbortError') {+ return;+ }+ console.error('WebOTP verification error:', err);+ }+}++otpForm.addEventListener('submit', async (event) => {+ // MANDATORY: Abort any in-flight WebOTP request when the form is submitted+ stopSmsOtpListener();++ // Application-specific submission logic (e.g., AJAX fetch or native POST)+ event.preventDefault();+ const formData = new FormData(otpForm);+ // await fetch(otpForm.action, { method: 'POST', body: formData });+});++// Start listening when the OTP verification step becomes active+startSmsOtpListener();+```++## Cross-origin iframe verification++Receiving an SMS OTP inside a cross-origin `<iframe>` is restricted by default and is primarily used for embedded payment confirmation flows (such as 3D Secure verification where `shop.example` embeds an issuer challenge from `bank.example`). Supporting WebOTP inside a cross-origin `<iframe>` requires three coordinated configurations:++1. **Bind both origins on the last line of the SMS**: List the top-level embedding domain first (`@shop.example`), followed by `#<otp>`, followed by a space and the embedded iframe domain (`@bank.example`):++```text+Your verification code is 123456.+[email protected] #123456 @bank.example+```++2. **Send the `Permissions-Policy` HTTP response header**: Delegate `otp-credentials` to the cross-origin iframe origin in the parent document's HTTP headers:++```http+Permissions-Policy: otp-credentials=(self "https://bank.example")+```++3. **Add `allow="otp-credentials"` to the `<iframe>` element**: Explicitly grant the permission policy on the `<iframe>` tag in the embedding page and include a descriptive `title` attribute for screen readers:++```html+<iframe+ src="https://bank.example/verify"+ allow="otp-credentials"+ title="Payment verification">+</iframe>+```++Inside the `<iframe>` document served by `https://bank.example`, run the same `<form>` markup and `navigator.credentials.get({ otp: { transport: ['sms'] }, signal: ac.signal })` verification lifecycle shown above.++## Fallback strategies++### WebOTP API fallback++Browser support for WebOTP: Limited availability.+Supported by: Chrome 93 (Aug 2021), Edge 93 (Sep 2021), and Safari 27.+Unsupported in: Firefox.++If your target browsers do not support the WebOTP API (`OTPCredential`), do not load a third-party JavaScript polyfill, as reading incoming SMS messages requires operating-system-level integration. Instead, rely on the three-tier progressive enhancement built into the `<input>` markup:++- **Progressive enhancement experience**: Guard the `navigator.credentials.get({ otp: { transport: ['sms'] } })` call behind `if ('OTPCredential' in window)`. When `OTPCredential` is unavailable:+ 1. Browsers that support `autocomplete="one-time-code"` (such as Safari on iOS 14+, iPadOS, and macOS with iCloud SMS relay) parse the `@domain #code` SMS and present the code in the system keyboard autofill bar when the `<input>` is focused.+ 2. All other browsers fall back to manual entry in the single `<input type="text" inputmode="numeric" pattern="\d{6}" maxlength="6" required>`, displaying a numeric keypad on mobile devices and submitting via the `<button type="submit">`.++### Permissions Policy fallback++Browser support for Permissions policy: Limited availability.+Supported by: Chrome 108 (Nov 2022) and Edge 108 (Dec 2022).+Unsupported in: Firefox and Safari.++If the browser does not support delegating `otp-credentials` via `Permissions-Policy` and `<iframe allow="otp-credentials">`, the embedded verification `<form>` inside the cross-origin `<iframe>` degrades gracefully to `autocomplete="one-time-code"` keyboard suggestions and manual numeric input without throwing unhandled exceptions.++### Inputmode and AbortController support++Baseline status for inputmode: Widely available. It's been Baseline since 2021-12-07.+Supported by: Chrome 66 (Apr 2018), Edge 79 (Jan 2020), Firefox 95 (Dec 2021), Safari 12.1 (Mar 2019), and Safari iOS 12.2 (Mar 2019).++Baseline status for AbortController and AbortSignal: Widely available. It's been Baseline since 2019-03-25.+Supported by: Chrome 66 (Apr 2018), Edge 16 (Oct 2017), Firefox 57 (Nov 2017), Safari 12.1 (Mar 2019), and Safari iOS 12.2 (Mar 2019).++Both the HTML `inputmode` attribute and `AbortController` (`AbortSignal`) are supported across modern browsers and require no polyfill or fallback code.diff --git a/skills/modern-web-guidance/guides/html/accessible-web-components.md b/skills/modern-web-guidance/guides/html/accessible-web-components.mdindex dd6fc1e..02f9fde 100644--- a/skills/modern-web-guidance/guides/html/accessible-web-components.md+++ b/skills/modern-web-guidance/guides/html/accessible-web-components.md@@ -32,12 +32,12 @@ This avoids polluting the DOM with ARIA attributes and prevents consumers from a- Attach the shadow root with `delegatesFocus: true` when the component wraps focusable controls. Focusing the host then forwards focus to the first focusable child, and `:focus`/label clicks behave as users expect.- For roving focus or moving focus into a newly revealed region, give the target `tabindex="-1"` and call `.focus()`; make programmatically-focusable targets explicit rather than relying on tab order.-## ARIA relationships cannot cross shadow roots+## ARIA relationships across shadow roots-- **MANDATORY**: an `id` referenced by `aria-labelledby`, `aria-describedby`, `aria-controls`, etc. must live in the **same** tree as the referencing element. An attribute in the Light DOM cannot point at an `id` inside the shadow tree, and vice versa; the reference is silently ignored.-- Keep each ARIA relationship within one root. If a label in the shadow tree must describe a slotted Light DOM element, move the relationship into one tree (e.g. render the label in the Light DOM, or use `aria-label` text instead of an `id` reference).-- For element-to-element references that genuinely must cross roots, the emerging **Reference Target** mechanism is the standards direction, but it is not yet broadly available; design to keep references within a single tree today.-- The reflected ARIA *element* properties — `ariaLabelledByElements`, `ariaDescribedByElements`, and siblings — let you set these relationships to actual element references in JS, with no `id` needed. Browser support is still limited and the rules for referencing across shadow roots are constrained and evolving, so verify before relying on them; today, treat them mainly as a cleaner way to wire *same-tree* relationships without minting ids.+- **MANDATORY**: an `id` referenced by `aria-labelledby`, `aria-describedby`, `aria-controls`, etc. resolves only within the referencing element's **own** tree. An `id`-based attribute in the Light DOM cannot point at an `id` inside a shadow tree, and vice versa; the reference is silently ignored.+- To cross the boundary, use the reflected ARIA *element* properties (e.g. `ariaLabelledByElements`, `ariaDescribedByElements`, etc), which take direct JS element references instead of ids. They resolve **outward**: an element inside a shadow tree can point at a target in the Light DOM or any ancestor tree (including slotted content), so you can label a shadow-internal control from Light DOM content — something `id` references can't express.+- They do **not** resolve **inward**: an element can't reference *into* a descendant shadow tree (e.g. a host can't be labelled by its own shadow content). For that direction the emerging **Reference Target** mechanism is the standards direction, but it is not yet broadly available.+- When a relationship can't be expressed either way, keep it within one tree (render the label in the same tree) or use `aria-label` text instead of an `id` reference.## Fallback strategies@@ -45,3 +45,8 @@ Baseline status for ARIA attribute reflection: Widely available. It's been BaselSupported by: Chrome 103 (Jun 2022), Edge 103 (Jun 2022), Firefox 119 (Oct 2023), and Safari 16.4 (Mar 2023).Where the `ElementInternals` ARIA mixin is unavailable, set the role and ARIA state as attributes on the host instead (`this.setAttribute('role', 'switch')`). It works everywhere, at the cost of putting attributes in the DOM that a consumer could override.++Baseline status for the api.Element.ariaLabelledByElements capability: Newly available. It's been Baseline since 2025-04-04.+Supported by: Chrome 135 (Apr 2025), Edge 135 (Apr 2025), Firefox 136 (Mar 2025), and Safari 16.4 (Mar 2023).++Where the reflected ARIA *element* properties are unavailable, use an `id`-based `aria-*` attribute for same-tree relationships; a cross-boundary label has no `id`-based equivalent, so fall back to `aria-label` text.diff --git a/skills/modern-web-guidance/guides/html/styling-web-components.md b/skills/modern-web-guidance/guides/html/styling-web-components.mdindex fbc48b5..ac65717 100644--- a/skills/modern-web-guidance/guides/html/styling-web-components.md+++ b/skills/modern-web-guidance/guides/html/styling-web-components.md@@ -120,7 +120,7 @@ Supported by: Chrome 99 (Mar 2022), Edge 99 (Mar 2022), Firefox 97 (Feb 2022), aBaseline status for Container queries: Widely available. It's been Baseline since 2023-02-14.Supported by: Chrome 105 (Sep 2022), Edge 105 (Sep 2022), Firefox 110 (Feb 2023), and Safari 16 (Sep 2022).-:host-context() has limited availability.+Browser support for :host-context(): Limited availability.Supported by: Chrome 54 (Oct 2016) and Edge 79 (Jan 2020).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/js/calculate-event-differentials.md b/skills/modern-web-guidance/guides/js/calculate-event-differentials.mdindex 1077078..86a6f9c 100644--- a/skills/modern-web-guidance/guides/js/calculate-event-differentials.md+++ b/skills/modern-web-guidance/guides/js/calculate-event-differentials.md@@ -62,7 +62,7 @@ if (isExpired) {### Fallbacks & browser support for Temporal-Temporal has limited availability.+Browser support for Temporal: Limited availability.Supported by: Chrome 144 (Jan 2026), Edge 144 (Jan 2026), and Firefox 139 (May 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/js/capture-location-agnostic-data.md b/skills/modern-web-guidance/guides/js/capture-location-agnostic-data.mdindex 6400ca8..b1c2c80 100644--- a/skills/modern-web-guidance/guides/js/capture-location-agnostic-data.md+++ b/skills/modern-web-guidance/guides/js/capture-location-agnostic-data.md@@ -40,7 +40,7 @@ console.log(new Intl.DateTimeFormat('en-GB', { timeZone: 'America/New_York' }).f### Fallbacks & browser support for Temporal-Temporal has limited availability.+Browser support for Temporal: Limited availability.Supported by: Chrome 144 (Jan 2026), Edge 144 (Jan 2026), and Firefox 139 (May 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/js/coordinate-global-events.md b/skills/modern-web-guidance/guides/js/coordinate-global-events.mdindex 2e77238..aca4c1b 100644--- a/skills/modern-web-guidance/guides/js/coordinate-global-events.md+++ b/skills/modern-web-guidance/guides/js/coordinate-global-events.md@@ -53,7 +53,7 @@ console.log(`Tokyo time: ${tokyoTime.toString()}`);### Fallback strategies-Temporal has limited availability.+Browser support for Temporal: Limited availability.Supported by: Chrome 144 (Jan 2026), Edge 144 (Jan 2026), and Firefox 139 (May 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/js/format-human-readable-durations.md b/skills/modern-web-guidance/guides/js/format-human-readable-durations.mdindex 68bb419..77eed4f 100644--- a/skills/modern-web-guidance/guides/js/format-human-readable-durations.md+++ b/skills/modern-web-guidance/guides/js/format-human-readable-durations.md@@ -36,7 +36,7 @@ console.log(formatter.format(balanced));### Fallbacks & browser support for Temporal-Temporal has limited availability.+Browser support for Temporal: Limited availability.Supported by: Chrome 144 (Jan 2026), Edge 144 (Jan 2026), and Firefox 139 (May 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/js/manage-recurring-intervals.md b/skills/modern-web-guidance/guides/js/manage-recurring-intervals.mdindex 908c301..bfc242b 100644--- a/skills/modern-web-guidance/guides/js/manage-recurring-intervals.md+++ b/skills/modern-web-guidance/guides/js/manage-recurring-intervals.md@@ -47,7 +47,7 @@ try {### Fallback strategies-Temporal has limited availability.+Browser support for Temporal: Limited availability.Supported by: Chrome 144 (Jan 2026), Edge 144 (Jan 2026), and Firefox 139 (May 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/js/model-partial-time-concepts.md b/skills/modern-web-guidance/guides/js/model-partial-time-concepts.mdindex a118740..b842b9e 100644--- a/skills/modern-web-guidance/guides/js/model-partial-time-concepts.md+++ b/skills/modern-web-guidance/guides/js/model-partial-time-concepts.md@@ -73,7 +73,7 @@ console.log(`Snoozed alarm: ${snoozedTime.toString()}`);### Fallbacks & browser support for Temporal-Temporal has limited availability.+Browser support for Temporal: Limited availability.Supported by: Chrome 144 (Jan 2026), Edge 144 (Jan 2026), and Firefox 139 (May 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/js/stabilize-reactive-state.md b/skills/modern-web-guidance/guides/js/stabilize-reactive-state.mdindex 20ee293..abaf4ae 100644--- a/skills/modern-web-guidance/guides/js/stabilize-reactive-state.md+++ b/skills/modern-web-guidance/guides/js/stabilize-reactive-state.md@@ -51,7 +51,7 @@ function extendDeadlineGood() {### Fallback strategies-Temporal has limited availability.+Browser support for Temporal: Limited availability.Supported by: Chrome 144 (Jan 2026), Edge 144 (Jan 2026), and Firefox 139 (May 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/js/support-global-calendar-systems.md b/skills/modern-web-guidance/guides/js/support-global-calendar-systems.mdindex 3163d74..38029fb 100644--- a/skills/modern-web-guidance/guides/js/support-global-calendar-systems.md+++ b/skills/modern-web-guidance/guides/js/support-global-calendar-systems.md@@ -77,7 +77,7 @@ const localizedDisplay = targetDate.toLocaleString('en-u-ca-hebrew', {## Fallback Strategy-Temporal has limited availability.+Browser support for Temporal: Limited availability.Supported by: Chrome 144 (Jan 2026), Edge 144 (Jan 2026), and Firefox 139 (May 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/performance/avoid-redundant-large-asset-downloads.md b/skills/modern-web-guidance/guides/performance/avoid-redundant-large-asset-downloads.mddeleted file mode 100644index 2a1c2d7..0000000--- a/skills/modern-web-guidance/guides/performance/avoid-redundant-large-asset-downloads.md+++ /dev/null@@ -1,135 +0,0 @@-# Avoid redundant large asset downloads--Large shared assets such as AI model weights, Wasm modules, game engine cores, or fully-bundled JavaScript libraries are often identical across many unrelated sites. Without a shared cache, each origin downloads and stores its own copy, even when the visitor's browser already holds the exact same bytes from a different site. The Cross-Origin Storage (COS) API, exposed via `navigator.crossOriginStorage`, lets origins store and retrieve such files by content hash instead of by URL, so one on-device copy can serve every site that needs it.--## How to implement--1. **Compute the asset's hash when you build or publish your site.** Hash the exact bytes of the large asset you serve (for example, a model file, a Wasm binary, or a third-party library such as three.js) with `crypto.subtle.digest()`, and include the result as a lowercase hex string in your built code. The hash is what identifies the file in COS, and computing it on page load would require downloading the file first.-2. **Feature-detect before use, then fall back immediately if it's absent.** Check `navigator.crossOriginStorage?.requestFileHandle` once up front. If COS isn't implemented in this browser, skip straight to a normal network fetch.-3. **Once support is confirmed, still call every method defensively.** Wrap each COS call in `try`/`catch`, as described in the "Handle rejections" section.-4. **Check COS before fetching from the network.** Call `requestFileHandle(hash)` first. If it resolves, read the file with `handle.getFile()` and skip the network entirely.-5. **Fall back to the network on any rejection.** A `NotFoundError` is a cache miss that never proves the file is absent.-6. **Store what you fetch.** After a network fetch, request a writable handle with `{ create: true }`, write the complete file, and close the stream, so the next origin that asks for the same hash can skip the download.-7. **Choose the `origins` scope deliberately.** Pick it from the resource's real distribution, as described in the "Sharing scope" section.--## Example code--At build time, compute the hash once and inline it into your code:--```javascript-// build-hash.js (Node.js)-import { readFile } from 'node:fs/promises';--const bytes = await readFile('dist/assets/shared-library.js');-const digest = await crypto.subtle.digest('SHA-256', bytes);-const hex = Array.from(new Uint8Array(digest), (byte) =>- byte.toString(16).padStart(2, '0'),-).join('');-```--At runtime, load every large shared asset through one reusable helper that looks the file up by that hash:--```javascript-/**- * Loads a large shared asset from COS when available, otherwise from the- * network, and stores network responses in COS for the next origin.- * @param {string} url The asset's real, working network URL.- * @param {{algorithm: string, value: string}} hash The build-time hash.- * @param {'*' | string[]} [origins] Sharing scope; omit for same-site only.- * @returns {Promise<Blob>}- */-async function loadAsset(url, hash, origins) {- // Feature-detect once, up front, and fall back to the network- // immediately if COS isn't implemented in this browser.- const supportsCOS = !!navigator.crossOriginStorage?.requestFileHandle;- // Set when Permissions Policy blocks COS in this context, since every- // further COS call here rejects the same way.- let blocked = false;-- if (supportsCOS) {- try {- // Check COS first. If another origin already stored this exact- // hash, this resolves with no network request at all.- const handle = await navigator.crossOriginStorage.requestFileHandle(hash);- return await handle.getFile();- } catch (err) {- // A NotFoundError does not prove the file is absent from COS. Fall- // back to the network either way; never treat it as fatal.- blocked = err.name === 'NotAllowedError';- }- }-- const response = await fetch(url);- const fileBlob = await response.blob();-- if (supportsCOS && !blocked) {- // Write back to the cache.- try {- const handle = await navigator.crossOriginStorage.requestFileHandle(hash, {- create: true,- // Only pass `origins` when the caller chose a scope, so omitting it- // keeps the same-site-only default.- ...(origins && { origins }),- });- const writable = await handle.createWritable();- await writable.write(fileBlob);- await writable.close();- // Never call getFile() on this handle before write()/close() has- // resolved; use the blob already in hand instead.- } catch {- // Storing is a nice-to-have for future visitors, not required for- // this page to work.- }- }-- return fileBlob;-}--const library = await loadAsset(- '/assets/shared-library.js',- {- algorithm: 'SHA-256',- // Example-only hash value; use the hex string from your build step.- value: '8f434346648f6b96df89dda901c5176b10a6d83961dd3c1ac88b59b2dc327aa4',- },- // MANDATORY: origins: '*' is only appropriate for genuinely popular,- // non-proprietary resources.- '*',-);-```--## Handle rejections--A browser that implements COS can still reject any call, so a passed feature-detection check never guarantees success. Fall back to the network on every rejection, and read the error name to decide what else to do:--- **`NotFoundError` from `requestFileHandle(hash)`:** an ordinary cache miss that never proves the file is absent. The file may not exist, your origin may be outside its sharing scope, a globally shared file may not be on the browser's list of popular hashes yet, or the browser may deliberately report a stored file as missing to protect privacy (GREASE'ing). Store the file after the network fetch as usual.-- **`NotAllowedError` from `requestFileHandle()`:** Permissions Policy blocks COS in this context, for example in a cross-origin iframe whose embedder didn't grant the `cross-origin-storage` feature (its default allowlist is `self`). Every further COS call in this context rejects the same way, so skip the write-back too.-- **`NotAllowedError` from `getFile()`:** you called it on a handle obtained with `{ create: true }` before your own write completed, which applies even when another origin already stored the file. Use the blob you already have.--## Sharing scope--Every Cross-Origin Storage (COS) surface takes a sharing scope that controls which origins can later retrieve the stored file. Pick the scope that matches the resource's real distribution:--- **Same-site only (default):** for resources that only your own site uses.-- **Explicit origin list:** for a small, trusted set of origins, for example proprietary assets shared between your own properties.-- **Global (`*`):** **MANDATORY:** only for genuinely popular, non-proprietary resources, such as open-weight AI models or widely used open-source libraries.--| Surface | Same-site only | Origin list | Global |-|---|---|---|---|-| `requestFileHandle()` `origins` option | Omit `origins` | Array of origin strings | `'*'` |-| HTML `crossoriginstorage` attribute | Valueless attribute | Space-separated origins | `"*"` |-| `crossOriginStorage` import attribute | Empty string (`''`) | Space-separated origins | `'*'` |-| CSS `cross-origin-storage()` modifier | No arguments | Comma-separated origin strings | `*` |--**MANDATORY:** An origin list only takes effect for origins that a `Cross-Origin-Storage-Allow-Origin` response header also names, for example `Cross-Origin-Storage-Allow-Origin: https://a.example, https://b.example`. The header comes from whoever supplies the bytes: the response of the page that calls `requestFileHandle()`, or the response of the fetched resource itself (the script, stylesheet, module, or font) for the HTML, import attribute, and CSS forms. Origins the header doesn't name are dropped, and if none remain, the file is stored with the same-site default. The same-site default and `*` need no header.--## Best practices--- **DO** write the complete file with `createWritable()` / `write()` / `close()` (or `pipeTo()`) every time you store, even if the file might already exist in COS.-- **DO** use `Promise.all()` over individual `requestFileHandle()` calls to look up several distinct hashes concurrently, since each call takes exactly one hash.--## Fallback strategy--Cross-Origin Storage (COS) is being implemented in Chromium and is not yet natively supported by any major browser. Until it ships, the Cross-Origin Storage browser extension adds it to Chrome and other Chromium-based browsers (from the Chrome Web Store), Firefox on desktop and Android (from Firefox Add-ons), and Safari on macOS, iOS, and iPadOS (from the App Store). The extension supports the literal syntax of the `navigator.crossOriginStorage` API, the HTML `crossoriginstorage` attribute, and the CSS `cross-origin-storage()` modifier. It does not support the literal `crossOriginStorage` import attribute, since import attribute syntax can't be polyfilled.--The COS API is a progressive enhancement over a normal network fetch. Guard every access to `navigator.crossOriginStorage` with a single up-front feature-detection check, and always keep a working network-fetch path as the fallback for browsers without COS support.diff --git a/skills/modern-web-guidance/guides/performance/batch-analytics-events.md b/skills/modern-web-guidance/guides/performance/batch-analytics-events.mdindex 118c1c6..37ba44d 100644--- a/skills/modern-web-guidance/guides/performance/batch-analytics-events.md+++ b/skills/modern-web-guidance/guides/performance/batch-analytics-events.md@@ -88,7 +88,7 @@ window.addEventListener('click', (event) => {## Browser support and fallback strategies-fetchLater has limited availability.+Browser support for fetchLater: Limited availability.Supported by: Chrome 135 (Apr 2025) and Edge 135 (Apr 2025).Unsupported in: Firefox and Safari.. Therefore, a fallback strategy is typically required.diff --git a/skills/modern-web-guidance/guides/performance/break-up-long-tasks.md b/skills/modern-web-guidance/guides/performance/break-up-long-tasks.mdindex ffedaa4..23c216e 100644--- a/skills/modern-web-guidance/guides/performance/break-up-long-tasks.md+++ b/skills/modern-web-guidance/guides/performance/break-up-long-tasks.md@@ -30,7 +30,7 @@ async function processLargeArray(items) {### Fallback strategies-Scheduler API has limited availability.+Browser support for Scheduler API: Limited availability.Supported by: Chrome 129 (Sep 2024), Edge 129 (Sep 2024), and Firefox 142 (Aug 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/performance/calculate-total-foreground-time.md b/skills/modern-web-guidance/guides/performance/calculate-total-foreground-time.mdindex 2f170e5..d24cb25 100644--- a/skills/modern-web-guidance/guides/performance/calculate-total-foreground-time.md+++ b/skills/modern-web-guidance/guides/performance/calculate-total-foreground-time.md@@ -48,7 +48,7 @@ function getTotalForegroundTime() {## Fallbacks & browser support-Page visibility state performance entries has limited availability.+Browser support for Page visibility state performance entries: Limited availability.Supported by: Chrome 115 (Jul 2023) and Edge 115 (Jul 2023).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/performance/detect-initial-visibility-state.md b/skills/modern-web-guidance/guides/performance/detect-initial-visibility-state.mdindex 1e8fbe7..30f82a5 100644--- a/skills/modern-web-guidance/guides/performance/detect-initial-visibility-state.md+++ b/skills/modern-web-guidance/guides/performance/detect-initial-visibility-state.md@@ -45,7 +45,7 @@ function getVisibilityInfo() {### Fallback strategies-Page visibility state performance entries has limited availability.+Browser support for Page visibility state performance entries: Limited availability.Supported by: Chrome 115 (Jul 2023) and Edge 115 (Jul 2023).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/performance/flicker-free-client-side-ab-testing.md b/skills/modern-web-guidance/guides/performance/flicker-free-client-side-ab-testing.mdindex cb0e0ca..3723311 100644--- a/skills/modern-web-guidance/guides/performance/flicker-free-client-side-ab-testing.md+++ b/skills/modern-web-guidance/guides/performance/flicker-free-client-side-ab-testing.md@@ -102,7 +102,7 @@ If the experiment logic is lightweight enough to inline, use an inline module sc## Fallback Strategies-blocking="render" has limited availability.+Browser support for blocking="render": Limited availability.Supported by: Chrome 105 (Sep 2022), Edge 105 (Sep 2022), and Safari 18.2 (Dec 2024).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/performance/full-session-analytics.md b/skills/modern-web-guidance/guides/performance/full-session-analytics.mdindex 288b59b..58ca8d5 100644--- a/skills/modern-web-guidance/guides/performance/full-session-analytics.md+++ b/skills/modern-web-guidance/guides/performance/full-session-analytics.md@@ -67,7 +67,7 @@ setInterval(queueBeacon, 10000);## Browser support and fallback strategies-fetchLater has limited availability.+Browser support for fetchLater: Limited availability.Supported by: Chrome 135 (Apr 2025) and Edge 135 (Apr 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/performance/identify-heavy-scripts.md b/skills/modern-web-guidance/guides/performance/identify-heavy-scripts.mdindex 7decd22..ce45e1e 100644--- a/skills/modern-web-guidance/guides/performance/identify-heavy-scripts.md+++ b/skills/modern-web-guidance/guides/performance/identify-heavy-scripts.md@@ -62,7 +62,7 @@ observer.observe({type: 'long-animation-frame', buffered: true});## Browser support and fallback strategies-Long animation frames performance entries has limited availability.+Browser support for Long animation frames performance entries: Limited availability.Supported by: Chrome 123 (Mar 2024) and Edge 123 (Mar 2024).Unsupported in: Firefox and Safari..diff --git a/skills/modern-web-guidance/guides/performance/identify-inp-causes.md b/skills/modern-web-guidance/guides/performance/identify-inp-causes.mdindex 9b71179..e45d11a 100644--- a/skills/modern-web-guidance/guides/performance/identify-inp-causes.md+++ b/skills/modern-web-guidance/guides/performance/identify-inp-causes.md@@ -66,7 +66,7 @@ Supported by: Chrome 76 (Jul 2019), Edge 79 (Jan 2020), Firefox 89 (Jun 2021), aThe Event Timing API is available in most modern browsers and is necessary to calculate INP and the INP subparts. For browsers that do not support this API INP cannot be measured.-Long animation frames performance entries has limited availability.+Browser support for Long animation frames performance entries: Limited availability.Supported by: Chrome 123 (Mar 2024) and Edge 123 (Mar 2024).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/performance/improve-next-page-load-performance.md b/skills/modern-web-guidance/guides/performance/improve-next-page-load-performance.mdindex 6696ada..8544146 100644--- a/skills/modern-web-guidance/guides/performance/improve-next-page-load-performance.md+++ b/skills/modern-web-guidance/guides/performance/improve-next-page-load-performance.md@@ -114,7 +114,7 @@ This example shows a rule set that prefetches all links eagerly, and then goes f## Browser support and fallback strategies-Speculation rules has limited availability.+Browser support for Speculation rules: Limited availability.Supported by: Chrome 109 (Jan 2023) and Edge 109 (Jan 2023).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/performance/interaction-paint-timing.md b/skills/modern-web-guidance/guides/performance/interaction-paint-timing.mdnew file mode 100644index 0000000..00c263c--- /dev/null+++ b/skills/modern-web-guidance/guides/performance/interaction-paint-timing.md@@ -0,0 +1,200 @@+# Measure interaction and soft-navigation paint timing++Standard paint and responsiveness metrics leave a measurement gap after the initial page load:++- **`LargestContentfulPaint` (`largest-contentful-paint`)** only measures the initial ("hard") document load and stops emitting entries as soon as the user first interacts with the page.+- **`PerformanceEventTiming` and `event` / Interaction to Next Paint (INP)** measures input responsiveness up to the *very next frame* (such as a button active state or loading spinner), but does not track subsequent asynchronous paints—such as new content rendered after a `fetch()` resolves, or a client-side route transition completes.+- Observing route changes in a Single Page App (SPA) can be difficult outside of framework code. Just monitoring URL updates can over report URL changes that are not linked to route changes (for example, anchor link changes, multiple "redirects" for a single route change).++The `InteractionContentfulPaint` (`interaction-contentful-paint`) and `PerformanceSoftNavigation` (`soft-navigation`) performance entry types fill this gap. They propagate interaction causality across asynchronous tasks (`fetch`, `await`, `setTimeout`) to attribute new contentful paints and Single-Page Application (SPA) route transitions directly back to the user interaction that triggered them.++## How to implement++### 1. Observe contentful paints triggered by interactions++Use a `PerformanceObserver` with `type: 'interaction-contentful-paint'` and `buffered: true` to observe progressively larger contentful paints attributable to any user interaction.++Each `InteractionContentfulPaint` entry provides:+- `interactionId`: The unique identifier of the initiating user interaction (matching `PerformanceEventTiming.interactionId` and `PerformanceSoftNavigation.interactionId`).+- `startTime`: The timestamp when the initiating user interaction started, relative to the initial hard navigation time origin.+- `paintTime` and `presentationTime`: When the rendering phase ended and when the painted pixels were drawn on screen.+- `duration`: The elapsed time from interaction start to paint presentation (`presentationTime - startTime`).+- `largestContentfulPaint`: A snapshot `LargestContentfulPaint` object containing details about the largest painted element for that interaction so far (`element`, `size`, `url`, `id`, `renderTime`, `loadTime`).++```javascript+/**+ * Observes contentful paints caused by user interactions and invokes a callback+ * whenever an interaction produces a larger contentful paint.+ *+ * @param {(entry: PerformanceEntry) => void} onInteractionPaint+ */+export function observeInteractionPaints(onInteractionPaint) {+ // Feature-detect support before calling observe() so unsupported browsers+ // do not throw or log console warnings.+ if (+ typeof PerformanceObserver === 'undefined' ||+ !PerformanceObserver.supportedEntryTypes?.includes('interaction-contentful-paint')+ ) {+ return null;+ }++ const observer = new PerformanceObserver((list) => {+ for (const entry of list.getEntries()) {+ // entry.duration is already calculated as (entry.presentationTime - entry.startTime),+ // giving the total time from the user interaction to this contentful paint.+ onInteractionPaint(entry);+ }+ });++ // MANDATORY: Pass buffered: true to capture interaction paints that occurred+ // before this observer was registered.+ observer.observe({ type: 'interaction-contentful-paint', buffered: true });+ return observer;+}+```++### 2. Measure Largest Contentful Paint (LCP) for SPA soft navigations++A soft navigation is emitted by the browser when a trusted user interaction causes both a visible URL change and a contentful paint. To calculate LCP for each soft navigation:++1. Observe both `'soft-navigation'` and `'interaction-contentful-paint'` entries with `buffered: true`.+2. **MANDATORY:** When a `'soft-navigation'` entry is received, seed its initial LCP candidate by calling `softNavEntry.getLargestInteractionContentfulPaint()`. If the application painted content *before* updating the URL (for example, rendering a view and then calling `history.pushState()`), those early `interaction-contentful-paint` entries were emitted before the `soft-navigation` entry and still carry the *previous* `navigationId`.+3. **MANDATORY:** Correlate subsequent `'interaction-contentful-paint'` entries to the active soft navigation by matching `entry.interactionId === softNavEntry.interactionId`, **DO NOT** match by `entry.navigationId`. Using `interactionId` ensures you include paints that occurred before the URL update and exclude paints from later, unrelated interactions on the new route.++```javascript+/**+ * Tracks FCP and LCP for each client-side soft navigation and reports finalized+ * route metrics when the user navigates to a new route or hides the page.+ *+ * @param {(report: {+ * url: string,+ * navigationId: number,+ * interactionId: number,+ * fcpDuration: number,+ * lcpDuration: number | null,+ * lcpElement: Element | null,+ * lcpSize: number | null+ * }) => void} onSoftNavReport+ */+export function trackSoftNavigationLCP(onSoftNavReport) {+ const supported =+ typeof PerformanceObserver !== 'undefined' &&+ PerformanceObserver.supportedEntryTypes?.includes('soft-navigation') &&+ PerformanceObserver.supportedEntryTypes?.includes('interaction-contentful-paint');++ if (!supported) {+ return null;+ }++ let activeSoftNav = null;+ let activeLcpEntry = null;++ function finalizeCurrentSoftNav() {+ if (!activeSoftNav) return;++ onSoftNavReport({+ // activeSoftNav.name holds the destination URL of the soft navigation.+ url: activeSoftNav.name,+ navigationId: activeSoftNav.navigationId,+ interactionId: activeSoftNav.interactionId,+ // activeSoftNav.duration is (activeSoftNav.presentationTime - activeSoftNav.startTime),+ // which represents First Contentful Paint (FCP) relative to interaction start.+ fcpDuration: activeSoftNav.duration,+ // activeLcpEntry.duration is (activeLcpEntry.presentationTime - activeSoftNav.startTime),+ // representing the soft navigation's LCP duration relative to interaction start.+ lcpDuration: activeLcpEntry ? activeLcpEntry.duration : null,+ lcpElement: activeLcpEntry?.largestContentfulPaint?.element ?? null,+ lcpSize: activeLcpEntry?.largestContentfulPaint?.size ?? null,+ });++ activeSoftNav = null;+ activeLcpEntry = null;+ }++ const softNavObserver = new PerformanceObserver((list) => {+ for (const softNavEntry of list.getEntries()) {+ // Finalize the previous route's metrics before resetting state for the new route.+ finalizeCurrentSoftNav();++ activeSoftNav = softNavEntry;+ // MANDATORY: Seed the LCP candidate with getLargestInteractionContentfulPaint()+ // to capture any attributed contentful paints that occurred before the URL updated.+ activeLcpEntry = softNavEntry.getLargestInteractionContentfulPaint();+ }+ });++ const icpObserver = new PerformanceObserver((list) => {+ for (const icpEntry of list.getEntries()) {+ // MANDATORY: Match by interactionId (not navigationId) so only paints caused+ // by the soft navigation's initiating interaction update the route's LCP.+ if (activeSoftNav && icpEntry.interactionId === activeSoftNav.interactionId) {+ activeLcpEntry = icpEntry;+ }+ }+ });++ softNavObserver.observe({ type: 'soft-navigation', buffered: true });+ icpObserver.observe({ type: 'interaction-contentful-paint', buffered: true });++ // Finalize the active route's LCP when the page is backgrounded or unloaded.+ document.addEventListener('visibilitychange', () => {+ if (document.visibilityState === 'hidden') {+ finalizeCurrentSoftNav();+ }+ });++ return { softNavObserver, icpObserver, finalizeCurrentSoftNav };+}+```++### 3. Measure Core Web Vitals across soft navigations with `web-vitals`++If your goal is to report standard Core Web Vitals (LCP, CLS, and INP) across both hard and soft navigations to an analytics endpoint, use the `web-vitals` library (v6.0.0+) with `{ reportSoftNavs: true }` rather than manually slicing every metric timeline.++```javascript+import { onLCP, onFCP, onCLS, onINP } from 'web-vitals';++function sendToAnalytics(metric) {+ // Example-only endpoint; replace with your real telemetry URL.+ navigator.sendBeacon(+ '/analytics',+ JSON.stringify({+ name: metric.name,+ value: metric.value,+ navigationType: metric.navigationType,+ navigationURL: metric.navigationURL,+ }),+ );+}++// Pass { reportSoftNavs: true } to report metrics per soft navigation in addition+// to the initial hard navigation.+onLCP(sendToAnalytics, { reportSoftNavs: true });+onFCP(sendToAnalytics, { reportSoftNavs: true });+onCLS(sendToAnalytics, { reportSoftNavs: true });+onINP(sendToAnalytics, { reportSoftNavs: true });+```++## Best practices++- **DO** feature-detect `'interaction-contentful-paint'` and `'soft-navigation'` using `PerformanceObserver.supportedEntryTypes?.includes(...)` before calling `observer.observe()`.+- **DO** pass `{ buffered: true }` when observing `'interaction-contentful-paint'` and `'soft-navigation'` so early entries are not missed if analytics code initializes asynchronously.+- **DO** call `softNavEntry.getLargestInteractionContentfulPaint()` when handling a new `soft-navigation` entry so paints that occurred prior to the URL update are included in LCP.+- **DO** match `interaction-contentful-paint` entries to a soft navigation using `interactionId`, not `navigationId`.+- **DO** use `entry.duration` (or `entry.presentationTime - entry.startTime`) to measure interaction paint latency, rather than reporting `entry.presentationTime` directly. All `PerformanceEntry` timestamps are measured from the initial hard page load time origin, not from the soft navigation start.+- **DO NOT** rely on `performance.getEntriesByType('soft-navigation')` to monitor long-lived single-page applications, as the browser's buffer is limited to the first 50 soft navigation entries.++## Fallback strategies++Browser support for Interaction contentful paint performance entries: Limited availability.+Supported by: Chrome 151 and Edge 151.+Unsupported in: Firefox and Safari.++Browser support for Soft navigation performance entries: Limited availability.+Supported by: Chrome 151 and Edge 151.+Unsupported in: Firefox and Safari.++If your Baseline target includes browsers that do not support `InteractionContentfulPaint` or `PerformanceSoftNavigation`, treat these APIs as a progressive enhancement for Real User Monitoring (RUM):++1. **Feature detection and graceful degradation:** Guard observer registration with `PerformanceObserver.supportedEntryTypes?.includes('interaction-contentful-paint')` and `PerformanceObserver.supportedEntryTypes?.includes('soft-navigation')`. In browsers lacking support, skip registering the observers so your application runs without throwing errors.+2. **Keep standard hard-navigation observers active:** Continue observing standard `'largest-contentful-paint'`, `'event'`, and `'layout-shift'` entries across all browsers. Because `LargestContentfulPaint` is finalized on the first user interaction regardless of soft-navigation support, measuring soft navigations in supporting browsers does not alter or break initial hard-load LCP measurements.diff --git a/skills/modern-web-guidance/guides/performance/lazy-load-video-and-audio.md b/skills/modern-web-guidance/guides/performance/lazy-load-video-and-audio.mdnew file mode 100644index 0000000..efe63b0--- /dev/null+++ b/skills/modern-web-guidance/guides/performance/lazy-load-video-and-audio.md@@ -0,0 +1,192 @@+# Lazy load video and audio++Media elements (`<video>` and `<audio>`) and their associated resources (such as `<video poster>` images and preloaded metadata) consume significant network and storage bandwidth during initial page load. Even when `preload="metadata"` or `preload="none"` is set on a `<video>`, the browser eagerly fetches its `poster` image immediately, and `preload="metadata"` still initiates range requests for media headers across every player on the page.++Adding `loading="lazy"` to offscreen `<video>` and `<audio>` elements instructs the browser to defer all media network requests—including `poster` image downloads, `preload` hints, and `autoplay` execution—until the element reaches a browser-calculated distance from the visual viewport.++## How to implement++1. **Add `loading="lazy"` to offscreen media**: Apply `loading="lazy"` to `<video>` and `<audio>` elements positioned below the fold. Omit the `loading` attribute on above-the-fold media so it defaults to `eager`.+2. **Set explicit `width` and `height` on `<video>` elements**: Always specify integer `width` and `height` attributes (in CSS pixels) on `<video>`. Unloaded videos default to `300`×`150` dimensions; without explicit sizing, a lazy-loaded video may fail to intersect the visible viewport and never load, or cause disruptive layout shifts (CLS) when it loads.+3. **Include the `controls` attribute on `<audio>` elements**: Always include `controls` on `<audio loading="lazy">`. Because `<audio>` elements have no intrinsic visual box without browser controls, an `<audio loading="lazy">` element without `controls` cannot visibly intersect the viewport and will never load or autoplay.+4. **Coordinate `preload` and `poster` attributes**:+ - On `<video loading="lazy">`, both the `poster` image fetch and the `preload` behavior (`none`, `metadata`, or `auto`) are deferred until the video approaches the viewport.+ - Pair `loading="lazy"` with `preload="none"` when the user must explicitly press play after scrolling to the media, or `preload="metadata"` when duration and initial frame data should populate automatically once the player enters the viewport.+5. **Handle lazy `autoplay` safely**: When `loading="lazy"` is combined with `autoplay` on a muted `<video>` (or an opt-in `<audio controls>`), playback and downloading wait until the element approaches the viewport. Always respect `@media (prefers-reduced-motion: reduce)` before autoplaying motion media.++## Example code++```html+<!-- Above-the-fold hero video: DO NOT use loading="lazy".+ Omit loading (defaults to "eager") so the poster and initial media load immediately. -->+<video+ controls+ width="1280"+ height="720"+ poster="/images/hero-poster.jpg"+ preload="metadata"+>+ <source src="/media/keynote.webm" type="video/webm">+ <source src="/media/keynote.mp4" type="video/mp4">+ <track src="/media/keynote-en.vtt" kind="captions" srclang="en" label="English">+</video>++<!-- Below-the-fold video player:+ MANDATORY: Specify integer width and height attributes so the unloaded video+ has a non-zero layout box to intersect the viewport and avoids layout shift.+ Both the poster image and preload="metadata" are deferred until near the viewport. -->+<video+ controls+ loading="lazy"+ width="800"+ height="450"+ poster="/images/tutorial-poster.jpg"+ preload="metadata"+>+ <source src="/media/tutorial.webm" type="video/webm">+ <source src="/media/tutorial.mp4" type="video/mp4">+ <track src="/media/tutorial-en.vtt" kind="captions" srclang="en" label="English">+</video>++<!-- Below-the-fold inline product loop:+ With loading="lazy" and autoplay, downloading and playback wait until the+ video approaches the viewport. Include muted and playsinline for autoplay. -->+<video+ controls+ loading="lazy"+ autoplay+ loop+ muted+ playsinline+ width="640"+ height="360"+ poster="/images/feature-loop-poster.jpg"+>+ <source src="/media/feature-loop.webm" type="video/webm">+ <source src="/media/feature-loop.mp4" type="video/mp4">+ <track src="/media/feature-loop-en.vtt" kind="captions" srclang="en" label="English">+</video>++<!-- Below-the-fold audio player:+ MANDATORY: Include the controls attribute. Lazy-loaded <audio> without+ controls is invisible, cannot intersect the viewport, and will never load. -->+<figure>+ <figcaption id="episode-title">Episode 42: Browser Architecture Deep Dive</figcaption>+ <audio+ controls+ loading="lazy"+ preload="metadata"+ src="/media/episode-42.mp3"+ aria-labelledby="episode-title"+ aria-details="episode-transcript"+ ></audio>+ <details id="episode-transcript">+ <summary>View transcript</summary>+ <p>Transcript content for Episode 42...</p>+ </details>+</figure>+```++```javascript+// Pause autoplaying videos when the user prefers reduced motion+const reducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');++function syncReducedMotion(prefersReducedMotion) {+ for (const video of document.querySelectorAll('video[autoplay]')) {+ if (prefersReducedMotion) {+ video.removeAttribute('autoplay');+ video.pause();+ }+ }+}++syncReducedMotion(reducedMotionQuery.matches);+reducedMotionQuery.addEventListener('change', (event) => {+ syncReducedMotion(event.matches);+});+```++## Best practices++- **MANDATORY**: Always set explicit `width` and `height` attributes on `<video>` elements. Unloaded videos have a `300`×`150` intrinsic size and will never load if they do not intersect a visible part of the page.+- **MANDATORY**: Always include the `controls` attribute on `<audio loading="lazy">` elements. Lazy-loaded `<audio>` elements without `controls` are not rendered visibly and will never load or autoplay.+- **DO NOT** apply `loading="lazy"` to above-the-fold or Largest Contentful Paint (LCP) `<video>` elements, as it delays fetching both the `poster` image and video data.+- **DO** omit the `loading` attribute when default eager loading is desired rather than explicitly writing `loading="eager"`.+- **DO NOT** rely on the `window` `load` event to detect when lazy-loaded `<video>` or `<audio>` elements have loaded. The `load` event fires based only on eager-loaded media, even if a `loading="lazy"` media element is initially inside the visual viewport.+- **DO** note that browsers only defer `loading="lazy"` media when JavaScript is enabled (an anti-tracking measure to prevent servers from inferring scroll position via media requests when scripting is disabled).++## Fallback strategy++Browser support for Lazy-loading media: Limited availability.+Supported by: Chrome 150 and Edge 150.+Unsupported in: Firefox and Safari.++If your Baseline target does not support `loading="lazy"` on `<video>` and `<audio>`, choose between progressive enhancement and an `IntersectionObserver` fallback based on how strictly bandwidth must be conserved:++### Progressive enhancement (recommended default)++Browsers that do not recognize `loading="lazy"` on `<video>` and `<audio>` ignore the attribute and fall back to standard loading governed by the `preload` attribute. Pairing `loading="lazy"` with `preload="none"` or `preload="metadata"` ensures unsupported browsers still avoid downloading the full media file upfront, though `<video poster>` images and `preload="metadata"` headers will be fetched eagerly.++### Custom code fallback (`IntersectionObserver`)++When your Baseline target requires strictly deferring `<video poster>` downloads, `preload="metadata"` requests, or viewport-triggered playback in browsers without native support, feature-detect `Object.hasOwn(HTMLMediaElement.prototype, 'loading')`, then fall back to `IntersectionObserver`:++```javascript+// Feature-detect native media lazy loading on HTMLMediaElement.prototype+const supportsLazyMedia = Object.hasOwn(HTMLMediaElement.prototype, 'loading');++if (!supportsLazyMedia) {+ const lazyMediaElements = document.querySelectorAll(+ 'video[loading="lazy"], audio[loading="lazy"][controls]',+ );++ // Example-only rootMargin value; adjust distance threshold for your layout+ const mediaObserver = new IntersectionObserver(+ (entries, observer) => {+ for (const entry of entries) {+ if (!entry.isIntersecting) continue;++ const media = entry.target;++ // Restore deferred poster and preload attributes when entering the viewport+ if (media.dataset.poster) {+ media.poster = media.dataset.poster;+ delete media.dataset.poster;+ }++ if (media.dataset.preload) {+ media.preload = media.dataset.preload;+ delete media.dataset.preload;+ }++ if (media.dataset.src) {+ media.src = media.dataset.src;+ delete media.dataset.src;+ }++ for (const source of media.querySelectorAll('source[data-src]')) {+ source.src = source.dataset.src;+ delete source.dataset.src;+ }++ media.load();+ observer.unobserve(media);+ }+ },+ { rootMargin: '200px 0px' },+ );++ for (const media of lazyMediaElements) {+ // Hold back network fetches in unsupported browsers until intersection+ if (media.hasAttribute('poster')) {+ media.dataset.poster = media.getAttribute('poster');+ media.removeAttribute('poster');+ }+ if (media.hasAttribute('preload') && media.getAttribute('preload') !== 'none') {+ media.dataset.preload = media.getAttribute('preload');+ }+ media.preload = 'none';+ mediaObserver.observe(media);+ }+}+```diff --git a/skills/modern-web-guidance/guides/performance/load-shared-resources-declaratively.md b/skills/modern-web-guidance/guides/performance/load-shared-resources-declaratively.mddeleted file mode 100644index ec79d73..0000000--- a/skills/modern-web-guidance/guides/performance/load-shared-resources-declaratively.md+++ /dev/null@@ -1,86 +0,0 @@-# Load shared resources declaratively--Popular scripts, stylesheets, and JavaScript modules, such as UI frameworks or widget libraries served from a CDN, are byte-for-byte identical across many unrelated sites, yet every site's visitors download and cache their own copy. Cross-Origin Storage (COS) lets the browser keep one on-device copy of such a file, identified by its content hash, and serve it to every site that references the same bytes. Resources that already carry an `integrity` hash opt in through markup or import syntax alone: the `crossoriginstorage` attribute on `<link>` and `<script>` elements, or the `crossOriginStorage` import attribute on static and dynamic module imports. The browser handles the lookup, the network fallback, and storing the file, so no custom caching code is needed.--## How to implement--1. **Start from `integrity`.** Both declarative forms require an existing, valid `integrity` hash on the element or import, since that hash is what identifies the file in COS.-2. **Add the COS attribute alongside it.** For HTML, add `crossoriginstorage` to a `<link>` or `<script>` element. For module imports, add `crossOriginStorage` inside the same `with { ... }` block as `integrity`.-3. **Choose the sharing scope.** Pick it from the resource's real distribution, as described in the "Sharing scope" section.-4. **For module imports, use dynamic `import()` inside `try`/`catch`.** A static `import` with an unsupported `crossOriginStorage` key fails the whole module at parse time, and a dynamic `import()` with one rejects before fetching anything. Catch the rejection and import the same URL without the attribute.--## Example code--```html-<link- rel="stylesheet"- href="/assets/shared-widget.css"- integrity="sha256-example-only-hash"- crossorigin="anonymous"- crossoriginstorage="*"-/>-<script- src="/assets/shared-widget.js"- integrity="sha256-example-only-hash"- crossorigin="anonymous"- crossoriginstorage="*"- defer-></script>-```--```javascript-// MANDATORY: Use dynamic import() inside try/catch. A browser without-// native support for the crossOriginStorage import attribute rejects it-// before fetching anything, even when navigator.crossOriginStorage exists-// (for example, added by an extension), so that object is no signal for-// import attribute support.-let mod;-try {- mod = await import('/assets/shared-config.js', {- with: {- integrity: 'sha256-YKd8aU4ILF6re6EiM6lTEdAiGTFjVgVk9867zPSCAhs=',- crossOriginStorage: '*',- },- });-} catch {- // Fall back to a plain import of the same URL.- mod = await import('/assets/shared-config.js');-}-```--## Sharing scope--Every Cross-Origin Storage (COS) surface takes a sharing scope that controls which origins can later retrieve the stored file. Pick the scope that matches the resource's real distribution:--- **Same-site only (default):** for resources that only your own site uses.-- **Explicit origin list:** for a small, trusted set of origins, for example proprietary assets shared between your own properties.-- **Global (`*`):** **MANDATORY:** only for genuinely popular, non-proprietary resources, such as open-weight AI models or widely used open-source libraries.--| Surface | Same-site only | Origin list | Global |-|---|---|---|---|-| `requestFileHandle()` `origins` option | Omit `origins` | Array of origin strings | `'*'` |-| HTML `crossoriginstorage` attribute | Valueless attribute | Space-separated origins | `"*"` |-| `crossOriginStorage` import attribute | Empty string (`''`) | Space-separated origins | `'*'` |-| CSS `cross-origin-storage()` modifier | No arguments | Comma-separated origin strings | `*` |--**MANDATORY:** An origin list only takes effect for origins that a `Cross-Origin-Storage-Allow-Origin` response header also names, for example `Cross-Origin-Storage-Allow-Origin: https://a.example, https://b.example`. The header comes from whoever supplies the bytes: the response of the page that calls `requestFileHandle()`, or the response of the fetched resource itself (the script, stylesheet, module, or font) for the HTML, import attribute, and CSS forms. Origins the header doesn't name are dropped, and if none remain, the file is stored with the same-site default. The same-site default and `*` need no header.--## Best practices--- **DO** keep the `src`/`href`/module specifier pointing at the resource's real, working network URL, since a COS lookup that doesn't succeed falls back to that URL exactly like ordinary `integrity`-checked fetches do.-- **DO NOT** introduce a separate imperative fetch/cache step in JavaScript for a resource that already carries `integrity`; add the declarative attribute instead.-- **DO NOT** confuse the HTML `crossoriginstorage` attribute with the unrelated `crossorigin` attribute. `crossorigin` sets the CORS request mode, and both can coexist on the same element.-- **DO NOT** confuse the CSS `cross-origin-storage()` modifier with the unrelated CSS `cross-origin()` modifier, which also sets the CORS request mode.--## Fallback strategy--Cross-Origin Storage (COS) is being implemented in Chromium and is not yet natively supported by any major browser. Until it ships, the Cross-Origin Storage browser extension adds it to Chrome and other Chromium-based browsers (from the Chrome Web Store), Firefox on desktop and Android (from Firefox Add-ons), and Safari on macOS, iOS, and iPadOS (from the App Store). The extension supports the literal syntax of the `navigator.crossOriginStorage` API, the HTML `crossoriginstorage` attribute, and the CSS `cross-origin-storage()` modifier. It does not support the literal `crossOriginStorage` import attribute, since import attribute syntax can't be polyfilled.--The HTML form degrades gracefully: a browser that doesn't recognize `crossoriginstorage` simply ignores the attribute, per ordinary HTML attribute-parsing rules, and the element still loads via its plain `href`/`src`. The static JavaScript import-attribute form does not degrade the same way, since an unrecognized `with` key is a hard failure; use dynamic `import()` inside `try`/`catch` as shown in the example.--With the extension installed, `navigator.crossOriginStorage` exists, but the literal import attribute still fails: a static `import` fails to parse, and a dynamic `import()` rejects. For module imports, the extension provides two non-standard shims:--- **`<script type="module-cos">`:** the extension reads the script as text, resolves every static or dynamic import that carries `crossOriginStorage` and has a literal string specifier, and runs the rewritten source as a regular module. Computed specifiers such as variables or template literals are not rewritten.-- **`navigator.crossOriginStorage.__non_standard__import(specifier, options)`:** takes the same arguments as dynamic `import()`, including a computed specifier.--**DO NOT** make either shim the only code path, since neither exists outside the extension.diff --git a/skills/modern-web-guidance/guides/performance/out-of-order-html-streaming.md b/skills/modern-web-guidance/guides/performance/out-of-order-html-streaming.mdindex 2dfd3bd..71975b5 100644--- a/skills/modern-web-guidance/guides/performance/out-of-order-html-streaming.md+++ b/skills/modern-web-guidance/guides/performance/out-of-order-html-streaming.md@@ -127,7 +127,7 @@ await response## Fallback strategies-<template for> has limited availability.+Browser support for <template for>: Limited availability.Supported by: Chrome 150 and Edge 150.Unsupported in: Firefox and Safari.@@ -135,7 +135,7 @@ HTML setter methods is not natively supported by any major browser yet.HTML streaming setters is not natively supported by any major browser yet.-HTML processing instructions has limited availability.+Browser support for HTML processing instructions: Limited availability.Supported by: Chrome 150 and Edge 150.Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/performance/performance.md b/skills/modern-web-guidance/guides/performance/performance.mdindex fdbbb34..32c6ecc 100644--- a/skills/modern-web-guidance/guides/performance/performance.md+++ b/skills/modern-web-guidance/guides/performance/performance.md@@ -152,6 +152,7 @@ Rendering involves Layout, Style, Paint, and Compositing calculations. CSS Conta### DOs* **DO use `content-visibility: auto` on off-screen sections on large, complex pages**: Instruct the browser to skip layout and paint calculations for entire subtrees until they approach the viewport.* **DO pair `content-visibility` with `contain-intrinsic-size`**: Prevent layout shifts and scrollbar jumping by providing a placeholder height/width for unrendered containers.+* **DO derive `contain-intrinsic-size` from the content**: When setting `contain-intrinsic-size` use the `auto` keyword and a value that's derived from what is known about the contents (i.e. text size, spacing, size of graphics, character count). Preferably use units such as `rem`, `lh`, `cap`, or `ch` that match values used for the elements within the contents rather than `px`. If the content for items in a group is not consistently sized, then use an average size.* **DO apply explicit CSS containment (`contain`)**: For isolated UI components (like modals or widgets), use `contain: layout style paint` to prevent internal changes from triggering page-wide reflows.### DON'Ts@@ -170,6 +171,18 @@ Rendering involves Layout, Style, Paint, and Compositing calculations. CSS Contacontain-intrinsic-size: auto 600px; /* Provides a 600px placeholder */}+.row {+ --row-gap: .4rem;+ --title-height: 1lh;+ --description-height: 0.85lh;++ display: grid;+ row-gap: var(--row-gap);+ content-visibility: auto;+ /* The sum of the title height, row gap, and description height should be the size of the contents when skipped for rendering. */+ contain-intrinsic-block-size: auto calc(var(--title-height) + var(--row-gap) + var(--description-height));+}+/* Scope a complex widget to prevent layout thrashing */.isolated-widget {contain: layout style paint;diff --git a/skills/modern-web-guidance/guides/performance/schedule-tasks-by-priority.md b/skills/modern-web-guidance/guides/performance/schedule-tasks-by-priority.mdindex a65c653..c269d6b 100644--- a/skills/modern-web-guidance/guides/performance/schedule-tasks-by-priority.md+++ b/skills/modern-web-guidance/guides/performance/schedule-tasks-by-priority.md@@ -31,7 +31,7 @@ scheduler.postTask(() => {### Fallback strategies-Scheduler API has limited availability.+Browser support for Scheduler API: Limited availability.Supported by: Chrome 129 (Sep 2024), Edge 129 (Sep 2024), and Firefox 142 (Aug 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/performance/sequence-distributed-events.md b/skills/modern-web-guidance/guides/performance/sequence-distributed-events.mdindex 26a5c74..5f0eba3 100644--- a/skills/modern-web-guidance/guides/performance/sequence-distributed-events.md+++ b/skills/modern-web-guidance/guides/performance/sequence-distributed-events.md@@ -55,7 +55,7 @@ function analyzeTelemetry(sortedEvents) {## Fallback strategies-Temporal has limited availability.+Browser support for Temporal: Limited availability.Supported by: Chrome 144 (Jan 2026), Edge 144 (Jan 2026), and Firefox 139 (May 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/performance/share-web-fonts-across-origins.md b/skills/modern-web-guidance/guides/performance/share-web-fonts-across-origins.mddeleted file mode 100644index a2632b1..0000000--- a/skills/modern-web-guidance/guides/performance/share-web-fonts-across-origins.md+++ /dev/null@@ -1,51 +0,0 @@-# Share web fonts across origins--Large icon fonts, emoji fonts, and fonts with extensive Unicode coverage are downloaded across an enormous number of unrelated sites every day, even though most visitors already hold an identical copy from some other site that referenced the same font. The Cross-Origin Storage (COS) API reaches CSS through a new `cross-origin-storage()` request-url-modifier, used alongside the existing `integrity()` modifier inside an `@font-face` `src: url(...)` descriptor. This is the recommended path for shared web fonts, since the imperative JavaScript API is not a natural fit for resources referenced purely from CSS.--## How to implement--1. **Get the font's integrity hash.** `cross-origin-storage()` always pairs with `integrity()`; the integrity hash is what identifies the font file in COS.-2. **Add `cross-origin-storage()` to the `url()`.** Place it alongside `integrity()` inside the same `url()` function in the `src` descriptor.-3. **Choose the sharing scope.** Pick it from the font's real distribution, as described in the "Sharing scope" section.-4. **List the COS-enhanced source first, with a plain fallback after it.** `src` is a prioritized list; a browser uses the first alternative it can parse and load. Putting the plain `url()` first would mean it is always used and the COS-enhanced source is never tried.--## Example code--```css-@font-face {- font-family: 'Shared Emoji Font';- src:- /* MANDATORY: List the COS-enhanced source first, then the plain fallback. */- url('/fonts/shared-emoji.woff2' integrity('sha256-example-only-hash') cross-origin-storage(*)) format('woff2'),- url('/fonts/shared-emoji.woff2') format('woff2');-}-```--## Sharing scope--Every Cross-Origin Storage (COS) surface takes a sharing scope that controls which origins can later retrieve the stored file. Pick the scope that matches the resource's real distribution:--- **Same-site only (default):** for resources that only your own site uses.-- **Explicit origin list:** for a small, trusted set of origins, for example proprietary assets shared between your own properties.-- **Global (`*`):** **MANDATORY:** only for genuinely popular, non-proprietary resources, such as open-weight AI models or widely used open-source libraries.--| Surface | Same-site only | Origin list | Global |-|---|---|---|---|-| `requestFileHandle()` `origins` option | Omit `origins` | Array of origin strings | `'*'` |-| HTML `crossoriginstorage` attribute | Valueless attribute | Space-separated origins | `"*"` |-| `crossOriginStorage` import attribute | Empty string (`''`) | Space-separated origins | `'*'` |-| CSS `cross-origin-storage()` modifier | No arguments | Comma-separated origin strings | `*` |--**MANDATORY:** An origin list only takes effect for origins that a `Cross-Origin-Storage-Allow-Origin` response header also names, for example `Cross-Origin-Storage-Allow-Origin: https://a.example, https://b.example`. The header comes from whoever supplies the bytes: the response of the page that calls `requestFileHandle()`, or the response of the fetched resource itself (the script, stylesheet, module, or font) for the HTML, import attribute, and CSS forms. Origins the header doesn't name are dropped, and if none remain, the file is stored with the same-site default. The same-site default and `*` need no header.--## Best practices--- **DO** keep the plain fallback `url()` pointing at the font's real, working network location, since a COS lookup that doesn't succeed falls back to fetching from that URL exactly like ordinary `integrity`-checked font loads do.-- **DO NOT** confuse the HTML `crossoriginstorage` attribute with the unrelated `crossorigin` attribute. `crossorigin` sets the CORS request mode, and both can coexist on the same element.-- **DO NOT** confuse the CSS `cross-origin-storage()` modifier with the unrelated CSS `cross-origin()` modifier, which also sets the CORS request mode.--## Fallback strategy--Cross-Origin Storage (COS) is being implemented in Chromium and is not yet natively supported by any major browser. Until it ships, the Cross-Origin Storage browser extension adds it to Chrome and other Chromium-based browsers (from the Chrome Web Store), Firefox on desktop and Android (from Firefox Add-ons), and Safari on macOS, iOS, and iPadOS (from the App Store). The extension supports the literal syntax of the `navigator.crossOriginStorage` API, the HTML `crossoriginstorage` attribute, and the CSS `cross-origin-storage()` modifier. It does not support the literal `crossOriginStorage` import attribute, since import attribute syntax can't be polyfilled.--CSS's forgiving handling of comma-separated values means a browser that doesn't recognize `cross-origin-storage()`/`integrity()` drops only that one list item, not the whole declaration, so a plain fallback `url()` listed afterward still applies. No extra feature detection is required in CSS; the fallback source is always present as a later item in the same `src` list.diff --git a/skills/modern-web-guidance/guides/pwa/migrate-web-app-origin.md b/skills/modern-web-guidance/guides/pwa/migrate-web-app-origin.mdindex df865ac..ca2b1d7 100644--- a/skills/modern-web-guidance/guides/pwa/migrate-web-app-origin.md+++ b/skills/modern-web-guidance/guides/pwa/migrate-web-app-origin.md@@ -87,7 +87,7 @@ By default, a migration is suggested to users. To make the transition mandatory,## Fallbacks & browser support-Web app origin migration has limited availability.+Browser support for Web app origin migration: Limited availability.Supported by: Chrome 149 (Jun 2026) and Edge 149 (Jun 2026).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/security/local-network-access.md b/skills/modern-web-guidance/guides/security/local-network-access.mdindex c0db478..03ae6da 100644--- a/skills/modern-web-guidance/guides/security/local-network-access.md+++ b/skills/modern-web-guidance/guides/security/local-network-access.md@@ -163,7 +163,7 @@ Permissions-Policy: local-network=(self "https://setup.partner.example.com"), lo## Fallback Strategies-Local network access has limited availability.+Browser support for Local network access: Limited availability.Supported by: Chrome 142 (Oct 2025) and Edge 142 (Oct 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/security/passkey-authentication.md b/skills/modern-web-guidance/guides/security/passkey-authentication.mdindex fd1fd7d..f198027 100644--- a/skills/modern-web-guidance/guides/security/passkey-authentication.md+++ b/skills/modern-web-guidance/guides/security/passkey-authentication.md@@ -184,7 +184,7 @@ import 'webauthn-polyfills';### Signal API Synchronization Fallback-Web authentication signal methods has limited availability.+Browser support for Web authentication signal methods: Limited availability.Supported by: Chrome 132 (Jan 2025), Edge 132 (Jan 2025), and Safari 26 (Sep 2025).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/security/passkey-conditional-create.md b/skills/modern-web-guidance/guides/security/passkey-conditional-create.mdindex a020292..4ed96d4 100644--- a/skills/modern-web-guidance/guides/security/passkey-conditional-create.md+++ b/skills/modern-web-guidance/guides/security/passkey-conditional-create.md@@ -114,7 +114,7 @@ import 'webauthn-polyfills';### Signal API Synchronization Fallback-Web authentication signal methods has limited availability.+Browser support for Web authentication signal methods: Limited availability.Supported by: Chrome 132 (Jan 2025), Edge 132 (Jan 2025), and Safari 26 (Sep 2025).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/security/passkey-management.md b/skills/modern-web-guidance/guides/security/passkey-management.mdindex 9b42392..f258c26 100644--- a/skills/modern-web-guidance/guides/security/passkey-management.md+++ b/skills/modern-web-guidance/guides/security/passkey-management.md@@ -1,17 +1,18 @@# Passkey Management-This guide details how to enable users to view, rename, and delete their registered passkeys while keeping saved credentials perfectly synchronized between the server and the user's password managers using the Signal API.+This guide details how to enable users to view, rename, and delete their registered passkeys while keeping saved credentials and user profile details synchronized between the server and the user's password managers using the Signal API.## Server-Side Operations-Your backend database layer and endpoints MUST support common CRUD actions for registered credentials. Decoupled from framework-specific libraries, the server exposes endpoints to:+Your backend database layer and endpoints MUST support common CRUD actions for registered credentials as well as updating user profile details. Decoupled from framework-specific libraries, the server exposes endpoints to:1. **List all user credentials**: Fetch all `StoredPasskeyCredential` records matching the signed-in user's ID.-2. **Update credential names**: Accept a new custom string name for a specific credential ID and persist the update.+2. **Update credential names**: Accept a new custom nickname for a specific credential ID and persist the update on the server.3. **Delete credentials**: Remove a specific credential ID from the database.+4. **Update user account details**: Accept updated `name` (username) and `displayName` values for the signed-in user's profile so the client can synchronize them with the passkey provider.```javascript-// Node.js routing example for credential CRUD+// Node.js routing example for credential CRUD and user profile renamerouter.get('/api/credentials', checkUserAuthenticated, async (req, res) => {const list = await db.findCredentialsByUserId(req.user.id);return res.json(list);@@ -38,11 +39,17 @@ router.delete('/api/credential/:id', checkUserAuthenticated, async (req, res) =>await db.deleteCredential(id);return res.json({ success: true });});++router.put('/api/user', checkUserAuthenticated, async (req, res) => {+ const { name, displayName } = req.body;+ const updatedUser = await db.updateUser(req.user.id, { name, displayName });+ return res.json(updatedUser);+});```## Client-Side Management UI-Render a dedicated settings panel allowing users to easily audit and manage their registered authentication options:+Render a dedicated settings panel allowing users to easily audit and manage their registered authentication options and account profile details:1. **Display saved list**: Fetch list from your endpoint and render individual credential rows. If the response is empty, render a helpful empty-state message (e.g., "No passkeys found").2. **Map AAGUID Metadata**: For each passkey, lookup its `aaguid` property against your local registry to render its provider details. See [Determine the passkey provider from AAGUID](#aaguid) section for more details.@@ -51,34 +58,38 @@ Render a dedicated settings panel allowing users to easily audit and manage thei* **Provider/Custom Name**: AAGUID-derived name or user-renamed string.* **Registration Date**: The database-persisted raw epoch timestamp `registeredAt` formatted to a human-readable date for client display.* **Last Used Date**: The database-persisted raw epoch timestamp `lastUsedAt` formatted to a human-readable date (if present) for client display.- * **Rename Button**: Triggers a rename text input modal.- * **Delete Button**: Triggers deletion.-4. **Conditional "Create Passkey" Button**:- * Offer a prominent "Create passkey" registration trigger button on the management page. Before rendering this UI element, the page MUST feature-detect capabilities using `PublicKeyCredential.getClientCapabilities()` to verify platform authenticator is supported. If passkeys are unsupported, hide this button and gracefully encourage standard MFA enrollments instead.- * Allow registering a security key by omitting `authenticatorSelection.authenticatorAttachment` on `navigator.credentials.create()` call.+ * **Rename Button**: Triggers a rename action to update the credential's custom nickname on the server (`PUT /api/credential/:id`). Note: Renaming an individual passkey's nickname is a server-side label change and does NOT invoke `signalCurrentUserDetails()`.+ * **Delete Button**: Triggers deletion of the credential (`DELETE /api/credential/:id`) and synchronizes the remaining credential IDs via `signalAllAcceptedCredentials()`.+4. **User Account Rename UI**:+ * Provide a control allowing the user to update their account username (`name`) or `displayName` (`PUT /api/user`), and immediately synchronize the updated user details with the password manager via `PublicKeyCredential.signalCurrentUserDetails()`.+5. **Conditional "Create Passkey" Button**:+ * Offer a prominent "Create passkey" registration trigger button on the management page. Before rendering this UI element, the page MUST feature-detect capabilities using `PublicKeyCredential.getClientCapabilities()` to verify platform authenticator is supported. If passkeys are unsupported, hide this button and gracefully encourage standard MFA enrollments instead.+ * Allow registering a security key by omitting `authenticatorSelection.authenticatorAttachment` on `navigator.credentials.create()` call.## Signal API SynchronizationThe Signal API lets the application communicate credential states to password managers, keeping the user's synced vaults and your backend database in lockstep.-* **Parameter Encoding Rule**:- * All `userId` and credential ID parameters passed to Signal API methods (`signalAllAcceptedCredentials`, `signalCurrentUserDetails`) MUST be **Base64URL-encoded strings**.+* **Feature Detection & Parameter Encoding Rule**:+ * Always feature-detect Signal API methods before invoking them (`if (PublicKeyCredential.signalAllAcceptedCredentials)` and `if (PublicKeyCredential.signalCurrentUserDetails)`).+ * All `userId` and credential ID parameters passed to Signal API methods (`signalAllAcceptedCredentials`, `signalCurrentUserDetails`) MUST be **Base64URL-encoded strings**.* **Initiating Page Load Sync**:- * The application MUST invoke `signalAllAcceptedCredentials()` automatically in a `DOMContentLoaded` page load event listener.+ * The application MUST invoke `signalAllAcceptedCredentials()` automatically when the management page loads (for example, inside a `DOMContentLoaded` event listener, module initialization, or framework component mount hook such as `useEffect`).* **Management Updates Sync**:- * The application MUST invoke `signalAllAcceptedCredentials()` immediately within your delete credential click handler post-fetch.- * The application MUST invoke `signalCurrentUserDetails()` immediately within your username or display name rename click handler post-fetch.+ * The application MUST invoke `signalAllAcceptedCredentials()` immediately within your delete credential click handler post-fetch.+ * The application MUST invoke `signalCurrentUserDetails()` immediately within your user account rename (`name` or `displayName`) click handler post-fetch.```javascript// Client-side management synchronization ES module-import { listFetch, renameFetch, deleteFetch } from './api.js';+import { listFetch, renameCredentialFetch, updateUserFetch, deleteFetch } from './api.js';// Base64URL-encoded User ID string (illustration only)const base64UrlUserId = "M2YPl-KGnA8";async function syncAcceptedCredentials(currentCredentialsList) {+ if (!window.PublicKeyCredential || !PublicKeyCredential.signalAllAcceptedCredentials) return;try {- const credentialIds = currentCredentialsList.map(c => c.id); // Map of Base64URL credential ID strings+ const credentialIds = currentCredentialsList.map(c => c.id); // Array of Base64URL credential ID stringsawait PublicKeyCredential.signalAllAcceptedCredentials({rpId, // RP ID must match the one defined on the server@@ -95,7 +106,7 @@ async function loadManagementPanel() {const list = await response.json();renderUI(list);- // Sync on page load+ // Sync accepted credentials on initial loadawait syncAcceptedCredentials(list);}@@ -106,14 +117,24 @@ async function performDelete(credentialId) {const updatedList = await updatedResponse.json();renderUI(updatedList);- // Sync after deletion+ // Sync remaining accepted credentials after deletionawait syncAcceptedCredentials(updatedList);}}-async function performRename(rpId, userId, updatedName, updatedDisplayName) {- const response = await renameFetch({ name: updatedName, displayName: updatedDisplayName });+// Renaming a passkey's nickname updates the server record only+async function performCredentialRename(credentialId, newCredentialName) {+ const response = await renameCredentialFetch(credentialId, { name: newCredentialName });if (response.ok) {+ const updatedResponse = await listFetch();+ renderUI(await updatedResponse.json());+ }+}++// Renaming the user's account username or displayName triggers signalCurrentUserDetails+async function performUserRename(rpId, userId, updatedName, updatedDisplayName) {+ const response = await updateUserFetch({ name: updatedName, displayName: updatedDisplayName });+ if (response.ok && window.PublicKeyCredential && PublicKeyCredential.signalCurrentUserDetails) {try {await PublicKeyCredential.signalCurrentUserDetails({rpId, // RP ID must match the one defined on the server@@ -126,6 +147,8 @@ async function performRename(rpId, userId, updatedName, updatedDisplayName) {}}}++window.addEventListener('DOMContentLoaded', loadManagementPanel);```## Determine the passkey provider from AAGUID {: #aaguid }@@ -195,7 +218,7 @@ import 'webauthn-polyfills';### Signal API Synchronization Fallback-Web authentication signal methods has limited availability.+Browser support for Web authentication signal methods: Limited availability.Supported by: Chrome 132 (Jan 2025), Edge 132 (Jan 2025), and Safari 26 (Sep 2025).Unsupported in: Firefox.If the browser does not support `PublicKeyCredential.parseRequestOptionsFromJSON`, use the 'webauthn-polyfills':@@ -209,3 +232,4 @@ If the browser does not support `PublicKeyCredential.parseRequestOptionsFromJSON```This will also add support for `PublicKeyCredential.prototype.toJSON`.+diff --git a/skills/modern-web-guidance/guides/security/passkey-registration.md b/skills/modern-web-guidance/guides/security/passkey-registration.mdindex 67ca6a7..e260d10 100644--- a/skills/modern-web-guidance/guides/security/passkey-registration.md+++ b/skills/modern-web-guidance/guides/security/passkey-registration.md@@ -160,7 +160,7 @@ async function registerPasskey(isPromotion = false) {### Signal API Synchronization Fallback-Web authentication signal methods has limited availability.+Browser support for Web authentication signal methods: Limited availability.Supported by: Chrome 132 (Jan 2025), Edge 132 (Jan 2025), and Safari 26 (Sep 2025).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/security/sanitize-untrusted-html.md b/skills/modern-web-guidance/guides/security/sanitize-untrusted-html.mdindex fe556d8..cb6bfe7 100644--- a/skills/modern-web-guidance/guides/security/sanitize-untrusted-html.md+++ b/skills/modern-web-guidance/guides/security/sanitize-untrusted-html.md@@ -64,7 +64,7 @@ preview.replaceChildren(...doc.body.childNodes);## Fallbacks & browser support for Sanitizer API-Sanitizer API has limited availability.+Browser support for Sanitizer API: Limited availability.Supported by: Chrome 146 (Mar 2026), Edge 146 (Mar 2026), and Firefox 148 (Feb 2026).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/ui-atoms/carousel-slide-effects.md b/skills/modern-web-guidance/guides/ui-atoms/carousel-slide-effects.mdindex c9eb278..e0db76d 100644--- a/skills/modern-web-guidance/guides/ui-atoms/carousel-slide-effects.md+++ b/skills/modern-web-guidance/guides/ui-atoms/carousel-slide-effects.md@@ -131,7 +131,7 @@ When using the `view-timeline` property to create a scroll-driven animation:## Browser support and fallback strategies-Scroll-driven animations has limited availability.+Browser support for Scroll-driven animations: Limited availability.Supported by: Chrome 115 (Jul 2023), Edge 115 (Jul 2023), and Safari 26 (Sep 2025).Unsupported in: Firefox.. Therefore, a fallback strategy is typically required.diff --git a/skills/modern-web-guidance/guides/ui-atoms/position-aware-tooltips.md b/skills/modern-web-guidance/guides/ui-atoms/position-aware-tooltips.mdindex 822997e..ed37233 100644--- a/skills/modern-web-guidance/guides/ui-atoms/position-aware-tooltips.md+++ b/skills/modern-web-guidance/guides/ui-atoms/position-aware-tooltips.md@@ -103,7 +103,7 @@ If you need to change properties on the container itself (like `margin` or `back## Fallback strategies-Anchor position container queries has limited availability.+Browser support for Anchor position container queries: Limited availability.Supported by: Chrome 143 (Dec 2025) and Edge 143 (Dec 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/ui-atoms/pull-to-reveal.md b/skills/modern-web-guidance/guides/ui-atoms/pull-to-reveal.mdindex a53c574..da15021 100644--- a/skills/modern-web-guidance/guides/ui-atoms/pull-to-reveal.md+++ b/skills/modern-web-guidance/guides/ui-atoms/pull-to-reveal.md@@ -59,7 +59,7 @@ To implement a pull-to-reveal pattern:## Fallback Strategy-scroll-initial-target has limited availability.+Browser support for scroll-initial-target: Limited availability.Supported by: Chrome 133 (Feb 2025) and Edge 133 (Feb 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/ui-atoms/resilient-context-menus-and-nested-dropdowns.md b/skills/modern-web-guidance/guides/ui-atoms/resilient-context-menus-and-nested-dropdowns.mdindex c2442f1..e5f44bb 100644--- a/skills/modern-web-guidance/guides/ui-atoms/resilient-context-menus-and-nested-dropdowns.md+++ b/skills/modern-web-guidance/guides/ui-atoms/resilient-context-menus-and-nested-dropdowns.md@@ -100,7 +100,7 @@ Without a bundler, import from a CDN inside a `<script type="module">`:Alternatively, for a legacy fallback without a polyfill, use `position: fixed` and manually calculate coordinates via `getBoundingClientRect()` or rely on default positioning with `inset: auto` if that's acceptable for the use case.-Anchor positioning has limited availability.+Browser support for Anchor positioning: Limited availability.Supported by: Safari 27.Unsupported in: Chrome, Edge, and Firefox.diff --git a/skills/modern-web-guidance/guides/ui-atoms/scroll-position-aware-elements.md b/skills/modern-web-guidance/guides/ui-atoms/scroll-position-aware-elements.mdindex f6c8562..44b9dbb 100644--- a/skills/modern-web-guidance/guides/ui-atoms/scroll-position-aware-elements.md+++ b/skills/modern-web-guidance/guides/ui-atoms/scroll-position-aware-elements.md@@ -55,7 +55,7 @@ Use the `@container` rule with the `scroll-state` function. To check if the user## Fallback strategies-Container scroll-state queries has limited availability.+Browser support for Container scroll-state queries: Limited availability.Supported by: Chrome 133 (Feb 2025) and Edge 133 (Feb 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/ui-atoms/scroll-progress-indicator.md b/skills/modern-web-guidance/guides/ui-atoms/scroll-progress-indicator.mdindex 83c6dcf..f88a0a5 100644--- a/skills/modern-web-guidance/guides/ui-atoms/scroll-progress-indicator.md+++ b/skills/modern-web-guidance/guides/ui-atoms/scroll-progress-indicator.md@@ -104,7 +104,7 @@ When using the `scroll-timeline` property to create a scroll-driven animation:## Fallback strategies-Scroll-driven animations has limited availability.+Browser support for Scroll-driven animations: Limited availability.Supported by: Chrome 115 (Jul 2023), Edge 115 (Jul 2023), and Safari 26 (Sep 2025).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/ui-atoms/scrollability-affordance-hints.md b/skills/modern-web-guidance/guides/ui-atoms/scrollability-affordance-hints.mdindex edb91fe..e125c73 100644--- a/skills/modern-web-guidance/guides/ui-atoms/scrollability-affordance-hints.md+++ b/skills/modern-web-guidance/guides/ui-atoms/scrollability-affordance-hints.md@@ -67,7 +67,7 @@ Use the `@container` rule with the `scroll-state` function. Check if the contain## Fallback strategies-Container scroll-state queries has limited availability.+Browser support for Container scroll-state queries: Limited availability.Supported by: Chrome 133 (Feb 2025) and Edge 133 (Feb 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/ui-atoms/shrinking-header-on-scroll.md b/skills/modern-web-guidance/guides/ui-atoms/shrinking-header-on-scroll.mdindex 6a4b5c7..b975494 100644--- a/skills/modern-web-guidance/guides/ui-atoms/shrinking-header-on-scroll.md+++ b/skills/modern-web-guidance/guides/ui-atoms/shrinking-header-on-scroll.md@@ -94,7 +94,7 @@ As for this use case specifically:## Browser support and fallback strategies-Scroll-driven animations has limited availability.+Browser support for Scroll-driven animations: Limited availability.Supported by: Chrome 115 (Jul 2023), Edge 115 (Jul 2023), and Safari 26 (Sep 2025).Unsupported in: Firefox.. Therefore, a fallback strategy is typically required.diff --git a/skills/modern-web-guidance/guides/ui-atoms/state-aware-sticky-headers.md b/skills/modern-web-guidance/guides/ui-atoms/state-aware-sticky-headers.mdindex f4164f7..438381e 100644--- a/skills/modern-web-guidance/guides/ui-atoms/state-aware-sticky-headers.md+++ b/skills/modern-web-guidance/guides/ui-atoms/state-aware-sticky-headers.md@@ -78,7 +78,7 @@ Apply `overflow-anchor: none` to the direct parent of the `position: sticky` eleDO NOT: Rely on `overflow-anchor: none` for elements stuck to the **bottom**. Scroll anchoring only compensates for layout shifts above the current scroll position, so it has no effect on bottom-stuck elements. Avoid changing box-model properties in the stuck state for bottom-stuck headers.### Fallback strategies-Container scroll-state queries has limited availability.+Browser support for Container scroll-state queries: Limited availability.Supported by: Chrome 133 (Feb 2025) and Edge 133 (Feb 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/anchor-positioning-tab-underline.md b/skills/modern-web-guidance/guides/ui-behaviors/anchor-positioning-tab-underline.mdindex 44c6627..7048296 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/anchor-positioning-tab-underline.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/anchor-positioning-tab-underline.md@@ -83,7 +83,7 @@ This is only a visual indicator, and must not be a replacement for setting the a## Fallback strategies-Anchor positioning has limited availability.+Browser support for Anchor positioning: Limited availability.Supported by: Safari 27.Unsupported in: Chrome, Edge, and Firefox.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/animate-element-entry-exit.md b/skills/modern-web-guidance/guides/ui-behaviors/animate-element-entry-exit.mdindex a0db24d..21fc98d 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/animate-element-entry-exit.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/animate-element-entry-exit.md@@ -35,7 +35,7 @@ To animate an element when toggling its visibility via an attribute (e.g., `hidd}/* Exit animation: transition TO these values when hidden */-.card:where(.hidden, [hidden]) {+.card[hidden] {display: none;opacity: 0;translate: 0 -20px;@@ -55,7 +55,7 @@ To animate an element when toggling its visibility via an attribute (e.g., `hidd}}- .card:where(.hidden, [hidden]) {+ .card[hidden] {translate: none;}}@@ -66,11 +66,11 @@ To animate an element when toggling its visibility via an attribute (e.g., `hiddFor elements added via `appendChild()` or removed via `remove()`:- **Entry**: Use `@starting-style` as shown above. The browser will automatically detect the style change from "nothing" to the element's initial styles and trigger the transition from the `@starting-style` values.-- **Removal**: Since `element.remove()` is instantaneous and doesn't trigger a CSS transition on its own, you must trigger the exit transition first (e.g., by adding a class) and wait for it to finish before removing the node from the DOM.+- **Removal**: Since `element.remove()` is instantaneous and doesn't trigger a CSS transition on its own, you must trigger the exit transition first and wait for it to finish before removing the node from the DOM.```javascript-// Trigger exit transition-element.setAttribute('hidden', true);+// 1. Trigger exit transition+element.hidden = true;// 2. Wait for all active transitions/animations to finish,// with a failsafe timeout in case an animation never ends (e.g. for looping animations)@@ -101,33 +101,92 @@ element.remove();Baseline status for @starting-style: Newly available. It's been Baseline since 2024-08-06.Supported by: Chrome 117 (Sep 2023), Edge 117 (Sep 2023), Firefox 129 (Aug 2024), and Safari 17.5 (May 2024).-For browsers that do not support these features, elements will toggle `display: none` instantly. You can detect support in JavaScript using `CSS.supports()` to conditionally apply manual animation logic.+### Fallbacks & browser support for transition-behavior-```javascript-// Detect support for discrete transitions and starting-style-const supportsModernTransitions =- window.CSS &&- CSS.supports('transition-behavior', 'allow-discrete');+Baseline status for transition-behavior: Newly available. It's been Baseline since 2024-08-06.+Supported by: Chrome 117 (Sep 2023), Edge 117 (Sep 2023), Firefox 129 (Aug 2024), and Safari 17.4 (Mar 2024).++Browser support for the css.properties.transition-behavior.transitionable_display capability: Limited availability.+Supported by: Chrome 117 (Sep 2023), Edge 117 (Sep 2023), and Safari 18 (Sep 2024).+Unsupported in: Firefox.++Firefox 129+ parses `transition-behavior: allow-discrete` (`CSS.supports('transition-behavior', 'allow-discrete')` returns `true`) without actually transitioning the `display` property (Firefox bug 1882408), causing elements to disappear immediately on exit.++To reliably detect discrete `display` transition support, probe whether a temporary element's computed `display` remains visible when transitioned to `none` rather than relying solely on `CSS.supports('transition-behavior', 'allow-discrete')`:-if (!supportsModernTransitions) {- // Implement manual JS-based fallback for entry/exit+```javascript+let supportsDisplayTransition;+function canTransitionDisplay() {+ if (supportsDisplayTransition !== undefined) return supportsDisplayTransition;+ if (!window.CSS?.supports?.('transition-behavior', 'allow-discrete') || !document.body) {+ return false;+ }+ const probe = document.createElement('div');+ // The shorthand is intentional here: browsers that don't parse allow-discrete+ // drop the whole declaration, so display: none applies instantly and the probe+ // correctly returns false. !important guards against global reduced-motion+ // resets like `* { transition: none !important }`.+ probe.style.cssText = 'transition: display 1s allow-discrete !important; display: block;';+ document.body.appendChild(probe);+ getComputedStyle(probe).display;+ probe.style.display = 'none';+ supportsDisplayTransition = getComputedStyle(probe).display === 'block';+ probe.remove();+ return supportsDisplayTransition;}```-### Manual Entry Animation (JS Fallback)+### Exit fallback when discrete `display` transitions are unsupported++Entry animations using `@starting-style` work across all modern browsers without JavaScript. When discrete `display` transitions are unsupported (`!canTransitionDisplay()`), setting `hidden` applies `display: none` immediately and skips the exit animation (both when hiding and before `element.remove()`). Separate the visual exit state (`[data-closing]`) from `display: none` (`[hidden]`) so `opacity` and `translate` finish animating before hiding or removing the element. Replace the `.card[hidden]` rules from step 1 (including the `prefers-reduced-motion` override) with:++```css+.card:where([hidden], [data-closing]) {+ opacity: 0;+ translate: 0 -20px;+}++.card[hidden] {+ display: none;+}++@media (prefers-reduced-motion: reduce) {+ .card:where([hidden], [data-closing]) {+ translate: none;+ }+}+``````javascript-// To show:-el.style.display = '';-requestAnimationFrame(() => {- requestAnimationFrame(() => {- el.classList.remove('hidden');- });-});--// To hide:-el.setAttribute('hidden', true);-el.addEventListener('transitionend', () => {- if (el.classList.contains('hidden')) el.style.display = 'none';-}, { once: true });+async function hideElement(el) {+ if (canTransitionDisplay()) {+ el.hidden = true;+ } else {+ el.setAttribute('data-closing', '');+ }++ const animations = el.getAnimations();+ if (animations.length > 0) {+ await Promise.race([+ Promise.allSettled(animations.map((a) => a.finished)),+ new Promise((r) => setTimeout(r, 2000)),+ ]);+ }++ // Skipped if showElement() cancelled the close mid-animation.+ if (el.hasAttribute('data-closing')) {+ el.removeAttribute('data-closing');+ el.hidden = true;+ }+}++function showElement(el) {+ el.removeAttribute('data-closing');+ el.hidden = false;+}++async function removeElement(el) {+ await hideElement(el);+ el.remove();+}```diff --git a/skills/modern-web-guidance/guides/ui-behaviors/animate-to-from-top-layer.md b/skills/modern-web-guidance/guides/ui-behaviors/animate-to-from-top-layer.mdindex e2eee60..23b9859 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/animate-to-from-top-layer.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/animate-to-from-top-layer.md@@ -54,11 +54,10 @@ dialog,dialog::backdrop,[popover]::backdrop {background-color: rgba(0, 0, 0, 0);- /* The transition shorthand can also be used with allow-discrete */- transition:- display 0.3s allow-discrete,- overlay 0.3s allow-discrete,- background-color 0.3s ease-out;+ transition-property: background-color, display, overlay;+ transition-duration: 0.3s;+ transition-timing-function: ease-out;+ transition-behavior: allow-discrete;}dialog[open]::backdrop,@@ -98,34 +97,110 @@ dialog[open]::backdrop,## Fallback strategies-### Top-layer animation features-Baseline status for @starting-style: Newly available. It's been Baseline since 2024-08-06.Supported by: Chrome 117 (Sep 2023), Edge 117 (Sep 2023), Firefox 129 (Aug 2024), and Safari 17.5 (May 2024).+Browser support for overlay: Limited availability.+Supported by: Chrome 117 (Sep 2023) and Edge 117 (Sep 2023).+Unsupported in: Firefox and Safari.++### Fallbacks & browser support for transition-behavior+Baseline status for transition-behavior: Newly available. It's been Baseline since 2024-08-06.Supported by: Chrome 117 (Sep 2023), Edge 117 (Sep 2023), Firefox 129 (Aug 2024), and Safari 17.4 (Mar 2024).-overlay has limited availability.-Supported by: Chrome 117 (Sep 2023) and Edge 117 (Sep 2023).-Unsupported in: Firefox and Safari.+Browser support for the css.properties.transition-behavior.transitionable_display capability: Limited availability.+Supported by: Chrome 117 (Sep 2023), Edge 117 (Sep 2023), and Safari 18 (Sep 2024).+Unsupported in: Firefox.++Firefox 129+ parses `transition-behavior: allow-discrete` (`CSS.supports('transition-behavior', 'allow-discrete')` returns `true`) without actually transitioning the `display` property (Firefox bug 1882408), causing elements to disappear immediately on exit.++To reliably detect discrete `display` transition support, probe whether a temporary element's computed `display` remains visible when transitioned to `none` rather than relying solely on `CSS.supports('transition-behavior', 'allow-discrete')`:++```javascript+let supportsDisplayTransition;+function canTransitionDisplay() {+ if (supportsDisplayTransition !== undefined) return supportsDisplayTransition;+ if (!window.CSS?.supports?.('transition-behavior', 'allow-discrete') || !document.body) {+ return false;+ }+ const probe = document.createElement('div');+ // The shorthand is intentional here: browsers that don't parse allow-discrete+ // drop the whole declaration, so display: none applies instantly and the probe+ // correctly returns false. !important guards against global reduced-motion+ // resets like `* { transition: none !important }`.+ probe.style.cssText = 'transition: display 1s allow-discrete !important; display: block;';+ document.body.appendChild(probe);+ getComputedStyle(probe).display;+ probe.style.display = 'none';+ supportsDisplayTransition = getComputedStyle(probe).display === 'block';+ probe.remove();+ return supportsDisplayTransition;+}+```++### Top-layer exit fallback++Entry animations work in pure CSS across all browsers that support `@starting-style`—no `.is-opening` class is needed because entry transitions do not depend on `overlay` or discrete `display` transitions.++Exit animations require both `overlay` and discrete `display` transition support. When either is unsupported (such as in Firefox and Safari), wrap the open-state selectors in `:is()` and append `:where(:not([data-closing]))` (nesting `&::backdrop` and `@starting-style`) so setting `data-closing` triggers the exit transition while the element remains in the top layer, then wait for `getAnimations()` to settle before calling `.close()` or `.hidePopover()`:++```css+:is(dialog[open], [popover]:popover-open):where(:not([data-closing])) {+ opacity: 1;+ transform: scale(1);++ @starting-style {+ opacity: 0;+ transform: scale(0.9);+ }-For browsers that do not support these features, top-layer elements will appear and disappear instantly. To provide animations in older browsers, you must use JavaScript to coordinate classes and wait for `transitionend` events or use the Web Animations API.+ &::backdrop {+ background-color: rgb(0 0 0 / 0.5);++ @starting-style {+ background-color: transparent;+ }+ }+}+``````javascript-// Feature detection for top-layer animations-const supportsTopLayerAnimation =- window.CSS &&- CSS.supports('transition-behavior', 'allow-discrete') &&- CSS.supports('overlay', 'auto');--if (!supportsTopLayerAnimation) {- // Manual JS fallback for entry/exit animations:- // 1. Add an `.is-opening` class for entry.- // 2. On close, add an `.is-closing` class, wait for the `transitionend` event, then call .close() or hide the popover.+// Evaluate lazily: canTransitionDisplay() needs document.body, so a top-level+// const would be permanently false if this script runs in <head>.+function supportsTopLayerExit() {+ return window.CSS?.supports?.('overlay', 'auto') && canTransitionDisplay();+}++async function closeTopLayer(element) {+ if (!supportsTopLayerExit()) {+ element.setAttribute('data-closing', '');+ const animations = element.getAnimations({ subtree: true });+ if (animations.length > 0) {+ await Promise.race([+ Promise.allSettled(animations.map((a) => a.finished)),+ new Promise((r) => setTimeout(r, 2000)),+ ]);+ }+ if (!element.hasAttribute('data-closing')) return;+ element.removeAttribute('data-closing');+ }++ element.close();+ // Or for popover:+ // element.hidePopover();}++// Route native close requests (Esc, closedby light dismiss) through the same+// helper so they animate too, instead of closing instantly.+dialog.addEventListener('cancel', (event) => {+ event.preventDefault();+ closeTopLayer(dialog);+});```+Popover light dismiss and `popovertarget` toggles cannot be intercepted (`beforetoggle` is only cancelable when opening), so in browsers that need the fallback those exits are instant. Provide an explicit close control that calls `closeTopLayer()` if the exit animation matters.+### Fallbacks & browser support for PopoverBaseline status for Popover: Newly available. It's been Baseline since 2025-01-27.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/carousel-snap-highlights.md b/skills/modern-web-guidance/guides/ui-behaviors/carousel-snap-highlights.mdindex 22d738e..e7c422d 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/carousel-snap-highlights.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/carousel-snap-highlights.md@@ -98,7 +98,7 @@ Snapping occurs due to scrolling, which does not move keyboard focus. However, k## Fallback strategies-Container scroll-state queries has limited availability.+Browser support for Container scroll-state queries: Limited availability.Supported by: Chrome 133 (Feb 2025) and Edge 133 (Feb 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/consistent-cross-document-transitions.md b/skills/modern-web-guidance/guides/ui-behaviors/consistent-cross-document-transitions.mdindex 4bb2732..169f2d9 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/consistent-cross-document-transitions.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/consistent-cross-document-transitions.md@@ -212,7 +212,7 @@ window.addEventListener('pagereveal', async (event) => {## Fallback Strategies-Cross-document view transitions has limited availability.+Browser support for Cross-document view transitions: Limited availability.Supported by: Chrome 126 (Jun 2024), Edge 126 (Jun 2024), and Safari 18.2 (Dec 2024).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/cross-document-transitions.md b/skills/modern-web-guidance/guides/ui-behaviors/cross-document-transitions.mdindex 283df56..fe30d7c 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/cross-document-transitions.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/cross-document-transitions.md@@ -101,7 +101,7 @@ Then, use the `:active-view-transition-type()` pseudo selector to apply the diffBaseline status for View transitions: Newly available. It's been Baseline since 2025-10-14.Supported by: Chrome 111 (Mar 2023), Edge 111 (Mar 2023), Firefox 144 (Oct 2025), and Safari 18 (Sep 2024).-Cross-document view transitions has limited availability.+Browser support for Cross-document view transitions: Limited availability.Supported by: Chrome 126 (Jun 2024), Edge 126 (Jun 2024), and Safari 18.2 (Dec 2024).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/interest-triggered-action-previews.md b/skills/modern-web-guidance/guides/ui-behaviors/interest-triggered-action-previews.mdindex 99269d5..5c76a06 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/interest-triggered-action-previews.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/interest-triggered-action-previews.md@@ -49,7 +49,7 @@ The start and end delay for an interest invoker (i.e. the element with the `inte### Fallback strategies-Interest invokers has limited availability.+Browser support for Interest invokers: Limited availability.Supported by: Chrome 142 (Oct 2025) and Edge 142 (Oct 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/interest-triggered-tooltips.md b/skills/modern-web-guidance/guides/ui-behaviors/interest-triggered-tooltips.mdindex eb0c51b..c66045c 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/interest-triggered-tooltips.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/interest-triggered-tooltips.md@@ -73,7 +73,7 @@ Also, the polyfill does not support `position-area` on popovers, so **MANDATORY:### Fallback strategies-Interest invokers has limited availability.+Browser support for Interest invokers: Limited availability.Supported by: Chrome 142 (Oct 2025) and Edge 142 (Oct 2025).Unsupported in: Firefox and Safari.@@ -126,13 +126,13 @@ Without a bundler, import from a CDN inside a `<script type="module">`:Alternatively, for a legacy fallback without a polyfill, use `position: fixed` and manually calculate coordinates via `getBoundingClientRect()` or rely on default positioning with `inset: auto` if that's acceptable for the use case.-popover="hint" has limited availability.+Browser support for popover="hint": Limited availability.Supported by: Chrome 151, Edge 151, and Firefox 153 (Jul 2026).Unsupported in: Safari.The `popover-polyfill` does not polyfill the hint behavior in browsers that support `popover` but not `popover="hint"`. For those browsers, a tooltip opened via focus may stay open when a second tooltip opened via hover.-Anchor positioning has limited availability.+Browser support for Anchor positioning: Limited availability.Supported by: Safari 27.Unsupported in: Chrome, Edge, and Firefox.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/light-dismiss-a-dialog.md b/skills/modern-web-guidance/guides/ui-behaviors/light-dismiss-a-dialog.mdindex 7bfe4df..a44821e 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/light-dismiss-a-dialog.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/light-dismiss-a-dialog.md@@ -51,7 +51,7 @@ dialog::backdrop {## Fallback strategies-<dialog closedby> has limited availability.+Browser support for <dialog closedby>: Limited availability.Supported by: Chrome 134 (Mar 2025), Edge 134 (Mar 2025), and Firefox 141 (Jul 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/motion.md b/skills/modern-web-guidance/guides/ui-behaviors/motion.mdnew file mode 100644index 0000000..a9223ad--- /dev/null+++ b/skills/modern-web-guidance/guides/ui-behaviors/motion.md@@ -0,0 +1,65 @@+# Motion++- Use `clip-path` and `mask-image` for custom geometric reveals and smooth fade-outs.+- Use **Scroll-Driven Animations** (`animation-timeline: scroll()`) for non-essential scroll-bound effects instead of JS listeners.+- Use **View Transitions** to animate between complex layout states seamlessly.++### Performance++- Prefer to animate `opacity` and `transform` (including individual transform properties, e.g. `translate` instead of `left/right/top/bottom`) to ensure animations stay on the compositor thread.+- Use `transition-behavior: allow-discrete`, `@starting-style`, and (for top-layer elements like `<dialog>` or `[popover]`) `overlay` to animate discrete entry and exit states natively; see `animate-element-entry-exit` (via `npx -y modern-web-guidance@latest retrieve "animate-element-entry-exit"`) and `animate-to-from-top-layer` (via `npx -y modern-web-guidance@latest retrieve "animate-to-from-top-layer"`).++```css+.popover-reveal {+ /* Transition discrete display and top-layer overlay alongside opacity */+ transition:+ opacity ease-out,+ display,+ overlay;+ transition-duration: 0.2s;+ transition-behavior: allow-discrete;+}+```++### Accessibility++Use `prefers-reduced-motion` media queries to turn off heavy motion for users who prefer it.+- **Provide Pause mechanism**: Allow users to stop auto-running carousels, banners, or other persistent animations.+- **Default to static views**: Consider defaulting to static states and allowing users to opt-in to motion.+- **Don't exceed flash limits (three per second)**: Never include rapid light-to-dark flashing. Such effects can cause seizures.++```css+/* Good: Dampen spin states for reduced motion queries */+@media (prefers-reduced-motion: reduce) {+ .spinner {+ animation: none;+ opacity: 0.5;+ }+}+```++**DO NOT** globally apply `animation-duration: 0.01ms;` globally as it can cause certain animations to become _more_ jarring.+Either apply reduced motion versions on a case by case basis, or use a custom property like:++```css+@property --animation-reduced {+ syntax: "*";+ inherits: false;+ initial-value: none;+}++@media (prefers-reduced-motion: reduce) {+ * {+ animation: var(--animation-reduced) !important;+ }+}+```++Then, reduced motion versions can be kept together with the original animations:++```css+progress:not([value]) {+ animation: slide 1s infinite linear;+ --animation-reduced: slide 20s infinite linear;+}+```diff --git a/skills/modern-web-guidance/guides/ui-behaviors/move-dom-element-without-losing-state.md b/skills/modern-web-guidance/guides/ui-behaviors/move-dom-element-without-losing-state.mdindex 97c84ea..f3739fe 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/move-dom-element-without-losing-state.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/move-dom-element-without-losing-state.md@@ -38,7 +38,7 @@ class MyCustomElement extends HTMLElement {### Fallback strategies-moveBefore() has limited availability.+Browser support for moveBefore(): Limited availability.Supported by: Chrome 133 (Feb 2025), Edge 133 (Feb 2025), and Firefox 144 (Oct 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/parallax-scroll-effects.md b/skills/modern-web-guidance/guides/ui-behaviors/parallax-scroll-effects.mdindex 5bf1df9..3ec8e01 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/parallax-scroll-effects.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/parallax-scroll-effects.md@@ -174,7 +174,7 @@ As for setting the `animation-range`:## Browser support and fallback strategies-Scroll-driven animations has limited availability.+Browser support for Scroll-driven animations: Limited availability.Supported by: Chrome 115 (Jul 2023), Edge 115 (Jul 2023), and Safari 26 (Sep 2025).Unsupported in: Firefox.. Therefore, a fallback strategy is typically required.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/persistent-top-layer-ui.md b/skills/modern-web-guidance/guides/ui-behaviors/persistent-top-layer-ui.mdindex 6f9764b..cc695f0 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/persistent-top-layer-ui.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/persistent-top-layer-ui.md@@ -19,7 +19,7 @@ newParent.moveBefore(dialogElement, null);### Fallback strategies-moveBefore() has limited availability.+Browser support for moveBefore(): Limited availability.Supported by: Chrome 133 (Feb 2025), Edge 133 (Feb 2025), and Firefox 144 (Oct 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/platform-controls-dismiss-dialog.md b/skills/modern-web-guidance/guides/ui-behaviors/platform-controls-dismiss-dialog.mdindex 59a4219..2b3bc6a 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/platform-controls-dismiss-dialog.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/platform-controls-dismiss-dialog.md@@ -33,7 +33,7 @@ If you also want “light dismiss” behavior, then you must set `closedby` to `## Fallback strategies-<dialog closedby> has limited availability.+Browser support for <dialog closedby>: Limited availability.Supported by: Chrome 134 (Mar 2025), Edge 134 (Mar 2025), and Firefox 141 (Jul 2025).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/scroll-entry-exit-effects.md b/skills/modern-web-guidance/guides/ui-behaviors/scroll-entry-exit-effects.mdindex 4887a1d..67b74d3 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/scroll-entry-exit-effects.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/scroll-entry-exit-effects.md@@ -137,7 +137,7 @@ Prefer a named `view-timeline` when multiple elements or children of the tracked## Browser support and fallback strategies-Scroll-driven animations has limited availability.+Browser support for Scroll-driven animations: Limited availability.Supported by: Chrome 115 (Jul 2023), Edge 115 (Jul 2023), and Safari 26 (Sep 2025).Unsupported in: Firefox.. Therefore, a fallback strategy is typically required.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/scroll-snap-realtime-feedback.md b/skills/modern-web-guidance/guides/ui-behaviors/scroll-snap-realtime-feedback.mdindex 4c888f7..f5ee403 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/scroll-snap-realtime-feedback.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/scroll-snap-realtime-feedback.md@@ -95,7 +95,7 @@ if (document.readyState === 'complete') {```### Fallback strategies-Scroll snap events has limited availability.+Browser support for Scroll snap events: Limited availability.Supported by: Chrome 129 (Sep 2024) and Edge 129 (Sep 2024).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/scroll-snap-state-sync.md b/skills/modern-web-guidance/guides/ui-behaviors/scroll-snap-state-sync.mdindex 2a249a4..e9dd92b 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/scroll-snap-state-sync.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/scroll-snap-state-sync.md@@ -60,7 +60,7 @@ In addition, be careful when using the `mandatory` value for `scroll-snap-type`,## Fallback strategies-Scroll snap events has limited availability.+Browser support for Scroll snap events: Limited availability.Supported by: Chrome 129 (Sep 2024) and Edge 129 (Sep 2024).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/scroll-target-on-load.md b/skills/modern-web-guidance/guides/ui-behaviors/scroll-target-on-load.mdindex 4364624..6a43e23 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/scroll-target-on-load.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/scroll-target-on-load.md@@ -33,7 +33,7 @@ In this example, a feed starts scrolled to a specific "featured" item rather tha## Fallback Strategy-scroll-initial-target has limited availability.+Browser support for scroll-initial-target: Limited availability.Supported by: Chrome 133 (Feb 2025) and Edge 133 (Feb 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/scrollytelling.md b/skills/modern-web-guidance/guides/ui-behaviors/scrollytelling.mdindex dfc6ae2..9c4f909 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/scrollytelling.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/scrollytelling.md@@ -118,7 +118,7 @@ When using the `view-timeline` property to create a scroll-driven animation:## Fallback strategies-Scroll-driven animations has limited availability.+Browser support for Scroll-driven animations: Limited availability.Supported by: Chrome 115 (Jul 2023), Edge 115 (Jul 2023), and Safari 26 (Sep 2025).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/search-hidden-content.md b/skills/modern-web-guidance/guides/ui-behaviors/search-hidden-content.mdindex 2d16f50..984e66f 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/search-hidden-content.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/search-hidden-content.md@@ -118,7 +118,7 @@ accordion.addEventListener('beforematch', (e) => {Baseline status for <details>: Widely available. It's been Baseline since 2020-01-15.Supported by: Chrome 12 (Jun 2011), Edge 79 (Jan 2020), Firefox 49 (Sep 2016), and Safari 6 (Jul 2012).-hidden="until-found" has limited availability.+Browser support for hidden="until-found": Limited availability.Supported by: Chrome 102 (May 2022), Edge 102 (May 2022), and Firefox 148 (Feb 2026).Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/swipe-to-remove.md b/skills/modern-web-guidance/guides/ui-behaviors/swipe-to-remove.mdindex 21f9470..8e82d39 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/swipe-to-remove.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/swipe-to-remove.md@@ -462,7 +462,7 @@ All newer features that are used are either not core to the experience or have r### Fallback for `overscroll-behavior`-overscroll-behavior has limited availability.+Browser support for overscroll-behavior: Limited availability.Supported by: Chrome 144 (Jan 2026), Edge 144 (Jan 2026), and Firefox 150 (Apr 2026).Unsupported in: Safari.@@ -477,7 +477,7 @@ Hidden scrollbars are a visual enhancement, not the mechanism that makes swipe-t### Fallback for `scroll-initial-target`-scroll-initial-target has limited availability.+Browser support for scroll-initial-target: Limited availability.Supported by: Chrome 133 (Feb 2025) and Edge 133 (Feb 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/ui-components/dark-mode-toggle.md b/skills/modern-web-guidance/guides/ui-components/dark-mode-toggle.mdnew file mode 100644index 0000000..cec6288--- /dev/null+++ b/skills/modern-web-guidance/guides/ui-components/dark-mode-toggle.md@@ -0,0 +1,138 @@+# Dark mode toggles++A dark mode toggle lets users override the system color scheme for one site.+The override is applied by updating `<meta name="color-scheme">`: `light dark` means "follow the system preference", `light` or `dark` pin an explicit scheme.+Colors (`light-dark()`), system colors, and native UI all key off the CSS `color-scheme` property, so the toggle works by keeping that property in sync with the `<meta>` (see [Reflect the override in CSS](#reflect-the-override-in-css)).++## Persistent toggle, settings control, or no toggle at all?++Most sites do not need a persistent color scheme toggle in the site UI (header, nav, footer, etc.).+Follow the system preference by default and, if a manual override is needed at all, put the control in a separate settings surface: a settings page, panel, or overlay.++Pinning a scheme against the OS is a legitimate but rare intent, and rare intents belong behind progressive disclosure, not in a control that is visible at all times.++Persistent toggles are mostly found on developer-facing or developer-adjacent (e.g. for designers) sites, where switching schemes is a far more frequent task than it is for the average web user.+Do NOT add one just because it is a common pattern on developer sites: the developer's interest in this control is not representative of typical users.++## Implementation++First, follow all steps in `dark-mode` (via `npx -y modern-web-guidance@latest retrieve "dark-mode"`) to support both schemes, defaulting to the system preference.++### Data model++The data model for the dark mode toggle typically includes three states:+1. System (no stored value): The UI follows the system color scheme. Ideally this should be the default.+2. Light (stored as `"light"`): The UI uses the light theme regardless of the system color scheme.+3. Dark (stored as `"dark"`): The UI uses the dark theme regardless of the system color scheme.++This state is usually stored in `localStorage` and reflected in a `<meta name="color-scheme">` element in the document head.++### Reflect the override in CSS++The `<meta>` is only a *presentational hint*: any `color-scheme` declaration in author CSS overrides it.+Since `dark-mode` (via `npx -y modern-web-guidance@latest retrieve "dark-mode"`) sets `color-scheme: light dark` on `:root`, updating the `<meta>` alone is a **no-op** — CSS wins.+Map the `<meta>` back to the property so the cascade follows it:++```css+:root {+ color-scheme: light dark;++ &:has(> head > meta[name="color-scheme"][content="dark"]) {+ color-scheme: dark;+ }+ &:has(> head > meta[name="color-scheme"][content="light"]) {+ color-scheme: light;+ }+}+```++**DO NOT** hardcode `color-scheme: light` or `color-scheme: dark` as the root default; the base declaration MUST stay `light dark`.+CSS MUST NOT depend on JS: if JS never runs, the `<meta>` stays `light dark` and the site follows the system preference — nothing breaks.++### Persistence and FOUC prevention++Persist the override in `localStorage`; remove the entry when returning to the system default.++To avoid a flash of the wrong scheme, apply the stored value in an inline script (NOT `type=module`, NOT `defer`) placed immediately after the `<meta>` element:++```html+<meta name="color-scheme" content="light dark">+<script>+document.querySelector('meta[name="color-scheme"]').content = localStorage.getItem("color-scheme") ?? "light dark";+</script>+```++- This inline script exists **only** for FOUC prevention. Keep it as small as possible; additional JS for handling color scheme toggling can load later.+- In rare cases `localStorage` access can throw (e.g. site data blocked), but since this script does nothing else, the only side effect would be a console error. Wrap in `try .. catch` if this matters. Ensure the theme is still applied to the page, even if it cannot be persisted.+- The override can change from another tab: handle `window`'s `storage` event to stay in sync.+- **DO NOT** use `matchMedia()` to remove the stored value when the system preference changes to match it.+Many users' OS switches schemes automatically based on time of day; removing the stored value whenever the two happen to coincide would make it impossible to pin a scheme at all.++### Branching for HTML and non-color values++Colors need no extra work: once the `<meta>` is mapped to `color-scheme` (above), `light-dark()` follows the override.+This section is about adapting other values (e.g. `font-weight`, media sources, etc.).++When the page simply follows the system preference, `(prefers-color-scheme: dark)` can be used for branching, including in `<picture>` or `<video>` sources.+Overriding the color scheme adds an additional complication: the system preference is no longer the source of truth, and for APIs that only accept media queries there is no direct alternative.++Do NOT rely exclusively on JS-applied classes like `.dark` for branching, as they will be incorrect if JS doesn't load and the OS default is dark.++You can combine the media query with a `:root:has(> head > meta[name="color-scheme"][content="dark"])` (or `light`) selector to branch.+See `selector-atrule-combinations` (via `npx -y modern-web-guidance@latest retrieve "selector-atrule-combinations"`) for details on how to implement this elegantly.++The control's own options are non-color branches too: include both states in the markup (icon plus visually hidden action text, e.g. "Switch to dark theme") and hide the inactive one via these selectors.+`display: none` also removes the redundant option from the AT so the control needs no JS to stay current when the system preference changes.++For in-HTML media, the only way right now is to include both versions as separate elements and toggle visibility appropriately.+Hiding `<source>` elements with `display: none` does not work.++## User Interface++### Two or three states?++In all cases, the UI MUST support reverting or setting the color scheme to system.++Prefer displaying two states in space-constrained toggles, such as persistent toggles in the site chrome (header, nav, footer, etc.) where space is limited and tweaking settings is usually orthogonal to the user goal.++A color scheme control in a separate settings surface (page, panel, or overlay) is a different scenario and MAY expose all three states explicitly ("Light", "Dark", "System"): there, the user is already making deliberate decisions about future behavior, and there is room to explain the options.++Three explicit states are also warranted if the site implements context-aware schemes (e.g. a dimmer light mode when the OS is dark), since "Light" and "System (currently light)" then genuinely differ.++### Two-state toggles++When such a control is used, it tends to be a temporary comfort adjustment ("it's too bright right now"), rather than ensuring the current state is preserved long-term.+Therefore, for two-state toggles, it is sufficient to display two out of three settings: system (so that the setting can be reverted) and the current opposite of system, stored as its current literal value.++The only two states should be:++1. **System default** — no stored value, `<meta>` content `light dark`. Displayed as its current resolved value (e.g. a sun icon when light).+2. **Override** — stored literally as `light` or `dark`.++Essentially, it is a tri-state control (`light dark`, `light`, `dark`) where the explicit state matching the current system preference is unreachable.++When the user toggles:++1. Target scheme = the opposite of the currently *rendered* scheme (stored value if any, else system preference). The user intent is "select the opposite of what I see right now", NOT "select the inverse of the system default".+2. If the target differs from the current system preference, store it literally.+3. If the target matches the current system preference, the user is undoing their adjustment: remove the stored value. DO NOT store it — that would invisibly pin the scheme against future system changes.+4. Set the `<meta>` content to the stored value, or `light dark` if none.++IMPORTANT: Divergence must be checked only at storage time, never retroactively: a stored value that the system preference later changes to match MUST be kept.+Many users' OS switches schemes automatically based on time of day; removing the stored value whenever the two happen to coincide would make it impossible to pin a scheme at all.++Example scenario, starting with the OS set to light:++1. The user toggles. Dark differs from the system preference, so `dark` is stored; the site turns dark.+2. The OS setting changes to dark. The site stays dark (the stored value now matches the system preference, but is kept).+3. The OS setting changes back to light. The site stays dark.+4. The user toggles. The target (light) matches the system preference, so the stored value is removed and the site follows the system again.++### Three-state toggles++When there is more space and users are already in the mindset of setting long-term preferences, a tri-state control can provide more clarity.+In this case, the data model cleanly maps to the three UI options: system, light, and dark.++To reduce cognitive load, the "system" option should also display what the current system setting is, for example via:+- Icon, e.g. a sun icon at the bottom right of the system icon+- Text, e.g. "System (Currently light)"diff --git a/skills/modern-web-guidance/guides/ui-components/navigation-drawer.md b/skills/modern-web-guidance/guides/ui-components/navigation-drawer.mdindex 3a95447..6b17dc0 100644--- a/skills/modern-web-guidance/guides/ui-components/navigation-drawer.md+++ b/skills/modern-web-guidance/guides/ui-components/navigation-drawer.md@@ -302,7 +302,7 @@ The popover API, the scroll-driven animation that fades the backdrop, and `scrol#### Backdrop fade fallback (no `animation-timeline` support):-Scroll-driven animations has limited availability.+Browser support for Scroll-driven animations: Limited availability.Supported by: Chrome 115 (Jul 2023), Edge 115 (Jul 2023), and Safari 26 (Sep 2025).Unsupported in: Firefox.@@ -321,7 +321,7 @@ if (!CSS.supports('animation-timeline: scroll()')) {#### Initial scroll position fallback (no `scroll-initial-target` support):-scroll-initial-target has limited availability.+Browser support for scroll-initial-target: Limited availability.Supported by: Chrome 133 (Feb 2025) and Edge 133 (Feb 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/ui-components/persistent-app-tours.md b/skills/modern-web-guidance/guides/ui-components/persistent-app-tours.mdindex 9096877..9ae64e3 100644--- a/skills/modern-web-guidance/guides/ui-components/persistent-app-tours.md+++ b/skills/modern-web-guidance/guides/ui-components/persistent-app-tours.md@@ -94,7 +94,7 @@ Alternatively, for a legacy fallback without a polyfill, use `position: fixed` a#### anchor-positioning-Anchor positioning has limited availability.+Browser support for Anchor positioning: Limited availability.Supported by: Safari 27.Unsupported in: Chrome, Edge, and Firefox.diff --git a/skills/modern-web-guidance/guides/ui-components/progress-ring.md b/skills/modern-web-guidance/guides/ui-components/progress-ring.mdindex a60f3c1..9b746a6 100644--- a/skills/modern-web-guidance/guides/ui-components/progress-ring.md+++ b/skills/modern-web-guidance/guides/ui-components/progress-ring.md@@ -146,7 +146,7 @@ If `@property` is not supported, the ring will jump to the new value instantly iIf the transition is absolutely necessary, you can check for `@property` support and use a `requestAnimationFrame()` loop to interpolate `--value` in older browsers.-background-clip: border-area has limited availability.+Browser support for background-clip: border-area: Limited availability.Supported by: Chrome 150, Edge 150, and Safari 18.2 (Dec 2024).Unsupported in: Firefox.@@ -162,7 +162,7 @@ For browsers that don't yet support `background-clip: border-area`, fall back to}```-attr() has limited availability.+Browser support for attr(): Limited availability.Supported by: Chrome 133 (Feb 2025), Edge 133 (Feb 2025), and Firefox 155.Unsupported in: Safari.diff --git a/skills/modern-web-guidance/guides/ui-components/scrollspy.md b/skills/modern-web-guidance/guides/ui-components/scrollspy.mdindex 95ed5bb..6924a2c 100644--- a/skills/modern-web-guidance/guides/ui-components/scrollspy.md+++ b/skills/modern-web-guidance/guides/ui-components/scrollspy.md@@ -82,7 +82,7 @@ nav a:target-current {## Fallback strategies-scroll-target-group has limited availability.+Browser support for scroll-target-group: Limited availability.Supported by: Chrome 140 (Sep 2025) and Edge 140 (Sep 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/ui-components/spinner.md b/skills/modern-web-guidance/guides/ui-components/spinner.mdindex 438509e..11fbdaf 100644--- a/skills/modern-web-guidance/guides/ui-components/spinner.md+++ b/skills/modern-web-guidance/guides/ui-components/spinner.md@@ -149,7 +149,7 @@ Supported by: Chrome 85 (Aug 2020), Edge 85 (Aug 2020), Firefox 128 (Jul 2024),If `@property` is supported, the dash animation is automatically included via the `--progress-dash-animation` property's `initial-value`. In browsers without `@property` support, the property registration is ignored, and the animation falls back to a simple rotation. No JavaScript is required for this fallback.-background-clip: border-area has limited availability.+Browser support for background-clip: border-area: Limited availability.Supported by: Chrome 150, Edge 150, and Safari 18.2 (Dec 2024).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/ui-components/stack-drill-down.md b/skills/modern-web-guidance/guides/ui-components/stack-drill-down.mdindex ed75acf..985208c 100644--- a/skills/modern-web-guidance/guides/ui-components/stack-drill-down.md+++ b/skills/modern-web-guidance/guides/ui-components/stack-drill-down.md@@ -616,7 +616,7 @@ The features that may require fallbacks are scroll-snap-events and scroll-driven#### Scroll snap events-Scroll snap events has limited availability.+Browser support for Scroll snap events: Limited availability.Supported by: Chrome 129 (Sep 2024) and Edge 129 (Sep 2024).Unsupported in: Firefox and Safari.@@ -663,7 +663,7 @@ if (!('onscrollsnapchange' in HTMLElement.prototype)) {#### Scroll-driven animations-Scroll-driven animations has limited availability.+Browser support for Scroll-driven animations: Limited availability.Supported by: Chrome 115 (Jul 2023), Edge 115 (Jul 2023), and Safari 26 (Sep 2025).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/visual-design/browser-ui-theming.md b/skills/modern-web-guidance/guides/visual-design/browser-ui-theming.mdnew file mode 100644index 0000000..9c8e8bb--- /dev/null+++ b/skills/modern-web-guidance/guides/visual-design/browser-ui-theming.md@@ -0,0 +1,39 @@+# Theming browser-generated UI++Most browser-generated UI can be customized to some extent using CSS.+Even if it requires modern features, it degrades gracefully in older browsers, and thus often does not require a polyfill or fallback.++Before re-creating browser UI (form controls, scrollbars, selections, error messages, etc), first verify that:+1. the browser UI cannot be customized enough for your needs, even with modern CSS,+2. the desired customization is sufficiently critical to justify the tradeoffs of re-creating built-in UI — most notably losing accessible semantics, keyboard handling, IME, and AT integration that the native UI provides for free.++Example customizations that are possible:+- Use `::selection` to customize highlighted text colors.+- **DON'T** apply `user-select: none` to content text — breaks copy-paste, translation tools, and AT "read from here" gestures. Limit it to chrome (drag handles, toolbars, redundant button labels).+- Use `accent-color` to apply the page's accent color to any browser-generated UI.+- Use `color-scheme` to have browser UI adapt to light/dark mode.+- Use `scrollbar-color` to customize scrollbar colors and `scrollbar-width` to control scrollbar thickness — keep the thumb visibly distinct from the track (≥3:1), and don't set `scrollbar-width: none` on scrollable regions (use it only when scrolling is fully replaced by another affordance).+- Use `:user-invalid` / `:user-valid` for validity styling, **not** `:invalid` / `:valid` — they only match after the user has interacted with the field, avoiding the hostile default of flagging required-empty fields as errors on page load.+- Buttons and text fields (including `<textarea>`) can generally be styled as normal elements.+- Use `font-size` to scale and other textual properties to control typography++### Styling textual fields (`<input>` & `<textarea>`)++For most styling purposes (e.g. colors, borders, backgrounds, typography, etc) treat these elements as normal text containers.++- Use `:placeholder-shown` and `::placeholder` to style input placeholders.+- Use `field-sizing: content` to make text fields size to content.+- For `<textarea>` elements, use `resize: vertical` to disable horizontal resizing or `resize: none` to disable all resizing.++### Multiple choice controls (select, radios, checkboxes)++- To select one among many options presented in a dropdown: Use a `<select>` + `appearance: base-select` + `::picker(select)`. For more info see `branded-select-styling` (via `npx -y modern-web-guidance@latest retrieve "branded-select-styling"`)+- Selecting one or more among multiple options laid out inline in the page: Use a `<input type=checkbox>` or `<input type=radio>` inside a `<label>` for each option. Style via `label:has(:checked)`.+- Style checkboxes, radios and switches via `appearance: none` + generated content (`::before`/`::after`) or background images to draw the checked state.+<!-- Customizable select listbox version currently buggy + this has much better browser support -->++### Non-textual `<input>`s (buttons, sliders, file inputs etc.)++- File inputs: Use `::file-selector-button` to style the button.+- Do not use `<input>` with a `type` of `button`, `submit` or `reset`. Use `<button>` instead and style it as a regular element.+- Sliders: Use `appearance: none` + thumb pseudo-elements (`::-webkit-slider-thumb`, `::-moz-range-thumb`, etc) and track pseudo-elements (`::-webkit-slider-runnable-track`, `::-moz-range-track`, etc) for more granular control.diff --git a/skills/modern-web-guidance/guides/visual-design/color.md b/skills/modern-web-guidance/guides/visual-design/color.mdnew file mode 100644index 0000000..dc493c3--- /dev/null+++ b/skills/modern-web-guidance/guides/visual-design/color.md@@ -0,0 +1,43 @@+# Color++## Accessible color++**Don't use color alone to indicate the presence of a user interface component or its state**: Use iconography and/or shape to help differentiate. Do not denote success/errors ONLY with color. Use icons or text.++```html+<!-- Good: Denotes state without colors alone -->+<div class="error-msg">+ <span aria-hidden="true">❌</span>+ <span>The password entered was invalid.</span>+</div>+```++### Contrast++- **Minimum contrast standards**: Maintain 4.5:1 for normal text and 3:1 for large text or icons.+- **Ensure non-text contrast standards**: Maintain a minimum contrast ratio of 3:1 for user interface component boundaries and states.+ - This includes visual elements (borders, backgrounds, box-shadows, underlines) that form the boundary or indicate the presence of a UI component (e.g., input field borders).+ - This also includes visual elements indicating active states within a component (e.g., checkbox checkmarks or switch thumbs).+ - **Caveat**: Meeting 3:1 non-text contrast can challenge minimalistic designs. Soft gradients or subtle inset/outset shadows can soften visual boundaries while satisfying accessibility requirements.+- **Use `prefers-contrast` only when warranted**: Reach for `@media (prefers-contrast: more)` when the design uses low-contrast accents (e.g., subtle borders, muted secondary text) that need to be reinforced; most sites that already meet baseline contrast won't need it.++### Light and dark color schemes++- **Support light and dark color schemes**: Honor `@media (prefers-color-scheme: dark)` and pair it with the `color-scheme` CSS property so form controls, scrollbars, and other UA-rendered surfaces match.+See `dark-mode` (via `npx -y modern-web-guidance@latest retrieve "dark-mode"`) for more details.++### Forced Colors Mode++- **Support Forced Colors Mode**: In Forced Colors Mode (High Contrast on Windows), the browser overrides author colors with system keywords and strips `background-image`, `box-shadow`, and `border-image`. Define system color fallbacks for color tokens using `@media (forced-colors: active)`.+- **Use `forced-color-adjust: none` only where color is essential information** (syntax highlighter, color picker swatch). **DON'T** use `forced-color-adjust: none` just to preserve aesthetics.+- **Don't rely on `background-image`, `box-shadow`, or `border-image` to convey borders, separators, or state**: They disappear in forced colors (and often in print too). If you must, ensure there's an alternative in forced colors mode, such as `outline` or `border` with system color keywords (`CanvasText`, `LinkText`, `ButtonText`, `Highlight`, `GrayText`, etc.).++## Generating tints++Before generating tints dynamically, check if you can use an existing, predefined, design token. This allows much more designer control and ensures consistency.++If you need to generate lighter or darker colors dynamically:+- **DO NOT** just adjust the lightness channel in `oklch`/`oklab` or `lch`/`lab`, e.g. `oklab(from var(--primary) 0.9 a b)`. While that is theoretically the correct way, browsers do not yet implement gamut mapping, so the resulting color is unpredictable.+- You can use `color-mix()` to mix with white or black (preferably in `oklab`). This keeps the color safely in gamut, but tends to over-desaturate colors and produce washed out tints and shades.+- You MAY combine lightness adjustment with any of the other methods (e.g. `color-mix(in oklab, oklch(from var(--primary) 0.9 c h), white 30%)`) for a balance between the two, but avoid going above 30% for the lightness adjustment.+diff --git a/skills/modern-web-guidance/guides/visual-design/dark-mode.md b/skills/modern-web-guidance/guides/visual-design/dark-mode.mdindex 4924b1d..4200277 100644--- a/skills/modern-web-guidance/guides/visual-design/dark-mode.md+++ b/skills/modern-web-guidance/guides/visual-design/dark-mode.md@@ -116,60 +116,31 @@ Most browser UI exposes pseudo-elements to fully customize its appearance, suchYou can use `light-dark()` colors on any of these to apply colors that adapt to the used color scheme.-## OPTIONAL: Implementing a color-scheme toggle+## 4. Varying images for light and dark mode-**DO NOT** set `color-scheme: light` or `color-scheme: dark` on the root element by default.-The default color-scheme MUST be the user's system preference, which happens automatically when setting `color-scheme` to `light dark`.+For CSS images, `light-dark()` can also be used to provide different image values.-For website-specific customization, a manual toggle could be provided to allow users to choose between light, dark, or system-default modes.+IMPORTANT: Both values in `light-dark()` must be the same type. You cannot combine a color with an image.+If one of the two must be an image, use `image(<color>)` to wrap the color value.-If a user-facing toggle to override it is desired, it should:-- Update the `<meta name="color-scheme">` element to reflect the chosen theme (`light dark` for system default, `light` for light, and `dark` for dark).-- If branching is desired for non-color values, set a class on `<html>` to match the theme preference and use descendant selectors. While `:root:has(> head > meta[name="color-scheme"][content="dark"])` would technically work, it is slower and confers no benefit, since we are already using JS to update the `<meta>` element.-- Persist user choice in `localStorage`.-- **IMPORTANT**: The CSS should be written to default to the system preference, with overrides for user-specified color-schemes. That way, if JS fails to execute, the site still defaults to the system color-scheme.-- The system-level OS theme can change at any time. If you are using JS to read `matchMedia("(prefers-color-scheme: dark)").matches`, you MUST also use `addEventListener("change", fn)` to react to changes. CSS automatically adapts to changes.-- **IMPORTANT**: To avoid a Flash of Unstyled Content (FOUC) for users who have pinned a different color scheme than their system default, use an inline script (NOT `type=module`, NOT `defer`) to set it when the page loads:+## JS-based theme detection-```html-<meta name="color-scheme" content="light dark">-<script>-{- const colorScheme = localStorage.getItem("color-scheme");- if (colorScheme) {- document.querySelector('meta[name="color-scheme"]').content = colorScheme;- }-}-</script>-```+Most color scheme branching should be done in CSS, which automatically adapts to changes.-### UX considerations+Any JS reading `matchMedia("(prefers-color-scheme: dark)").matches` MUST also handle its `change` event as the system preference can change at any time.-Use a two-state control:-1. System setting.-2. The opposite (e.g. light when the system setting is dark, and dark when the system setting is light). Selecting this setting must pin that exact color scheme, not a dynamically computed "opposite of system setting" value. Example scenario:- 1. The OS is set to light mode.- 2. The user selects the opposite setting for this website (dark).- 3. The user changes their system setting to dark.- 4. The website should remain dark.+## OPTIONAL: Implementing a color-scheme toggle-**DON'T** expose all three states (system, light, dark). While the rationale is plausible — "Follow system (currently dark)" is a distinct user intent from "Always dark" — it provides suboptimal UX:-- Users cannot meaningfully express intent for problems they don't currently have. A manual toggle is a temporary comfort adjustment ("it's too bright right now"), not a long-term preference ("make sure this never changes").-- Two of the three options always produce the same visual result, violating the principle of feedback.+If you want to allow users to manually override their system default for this site, you can implement a dark mode toggle.+Most sites do not need a persistent toggle in the site UI.+Simply defaulting to the system color scheme is usually enough, optionally with a setting in a separate settings surface.+See `dark-mode-toggle` (via `npx -y modern-web-guidance@latest retrieve "dark-mode-toggle"`) for best practices around implementing a dark mode toggle (persistent or not).-## Component-specific overrides+## OPTIONAL: Component-specific overridesYou can override the global theme for specific elements by setting `color-scheme` on them.-This is useful for "dark mode" sections within a light-themed site, such as code blocks or media players.--```css-pre, code {- /* Forces element and its children to use dark themed UI */- color-scheme: dark;-}-```-For more information about component-specific overrides and their gotchas, see `component-specific-light-dark-theme` (via `npx -y modern-web-guidance@latest retrieve "component-specific-light-dark-theme"`).+For more information and gotchas, see `component-specific-light-dark-theme` (via `npx -y modern-web-guidance@latest retrieve "component-specific-light-dark-theme"`).## Known issues to be aware of@@ -254,6 +225,76 @@ pre, code {}```+### Fallbacks & browser support for light-dark() image values++Baseline status for light-dark() image values: Newly available. It's been Baseline since 2026-09-14.+Supported by: Chrome 150, Edge 150, Firefox 150 (Apr 2026), and Safari 27.++For browsers that do not support `light-dark()` for images, use `image-set()` as a switch:+give each option a `type()` from a custom property, and set the inactive one to an unsupported MIME type so the browser discards that option.+The active option gets an empty value, so it is a plain `image-set()` option with no `type()`.++Define the switch once on `:root`. Every use site then only needs both images inline, like `light-dark()`.++```css+:root {+ --light-type: ;+ --dark-type: type("image/do-not-use");++ /* MANDATORY: Fallback for browsers without light-dark() image support */+ @media (prefers-color-scheme: dark) {+ --light-type: type("image/do-not-use");+ --dark-type: ;+ }+}++.hero {+ background-image: image-set(url(hero-light.png) var(--light-type), url(hero-dark.png) var(--dark-type));++ @supports (background-image: light-dark(url("a"), url("b"))) {+ background-image: light-dark(url(hero-light.png), url(hero-dark.png));+ }+}+```++- Only the selected image is downloaded.+- Resolutions still work: `image-set(url(a-1x.png) 1x var(--light-type), url(a-2x.png) 2x var(--light-type), url(b-1x.png) 1x var(--dark-type), url(b-2x.png) 2x var(--dark-type))`.+- **DO NOT** use `type("")` for the active option. Browsers treat the empty string as unsupported and drop every option.+- Unlike `light-dark()`, the switch does not follow `color-scheme` set on a subtree. A manual toggle, or any subtree that sets `color-scheme`, MUST also flip `--light-type` and `--dark-type`.++### Alternative: one custom property per image++Simpler when only a handful of images vary, but every image needs its own media query branch, and a manual toggle must flip each one.++```css+:root {+ --hero-image: url(hero-light.png);++ @media (prefers-color-scheme: dark) {+ --hero-image: url(hero-dark.png);+ }++ @supports (background-image: light-dark(url("a"), url("b"))) {+ --hero-image: light-dark(url(hero-light.png), url(hero-dark.png));+ }+}++.hero {+ background-image: var(--hero-image);+}+```++### Fallbacks & browser support for image()++image() is not natively supported by any major browser yet.++Use a gradient with a single color stop and no positions, e.g. `linear-gradient(blue)`.++Baseline status for the css.types.gradient.linear-gradient.single_color_stop capability: Newly available. It's been Baseline since 2025-04-04.+Supported by: Chrome 135 (Apr 2025), Edge 135 (Apr 2025), Firefox 136 (Mar 2025), and Safari 18.4 (Mar 2025).++For broader browser support, you can explicitly provide `0 100%` positions for the single color stop, e.g. `linear-gradient(blue 0 100%)`.+### Fallbacks & browser support for scrollbar-colorBaseline status for scrollbar-color: Newly available. It's been Baseline since 2025-12-12.@@ -288,7 +329,7 @@ If you are using custom properties to define colors, these will cascade to the l### Fallbacks & browser support for accent-color-accent-color has limited availability.+Browser support for accent-color: Limited availability.Supported by: Chrome 93 (Aug 2021), Edge 93 (Sep 2021), Firefox 92 (Sep 2021), and Safari 26.2 (Dec 2025).The `accent-color` property is progressive enhancement.diff --git a/skills/modern-web-guidance/guides/visual-design/equal-width-text-lines.md b/skills/modern-web-guidance/guides/visual-design/equal-width-text-lines.mdnew file mode 100644index 0000000..2d920d7--- /dev/null+++ b/skills/modern-web-guidance/guides/visual-design/equal-width-text-lines.md@@ -0,0 +1,97 @@+# Equal-Width Text Lines++Poster-style lockups where each line is scaled so it spans the container's full width can create visually striking headings.+Using `text-fit`, the browser scales each line during layout, so it stays correct on resize, copy changes, and font load.++For a single line filling its container (e.g. a heading or pull quote), see `fit-text-to-container` (via `npx -y modern-web-guidance@latest retrieve "fit-text-to-container"`) instead.++## Basic implementation++Note: Line breaks in a lockup are either **forced** (each line is its own block) or **free** (the browser wraps). This is a continuum: a lockup can be all forced, all free, or a mix.++For forced lines:+- Wrap each line in a `<span>` with `display: block`.+- Apply `white-space: nowrap` to each forced line `<span>`.++Implementation guidelines:+- Use `text-fit: grow per-line-all <percentage>` on the heading itself.+- Use `per-line-all`, not `per-line`. `per-line` skips the last line and any line ending in a forced break, so with one block per line it scales nothing.+- `grow` cannot be combined with `shrink`. Either set the base `font-size` to a maximum or a minimum depending on what would be a better fallback or easier to calculate, and set `text-fit` to `shrink` or `grow` accordingly. If you don’t have a reason to use `shrink`, prefer `grow` + setting `font-size` to a minimum, as it's safer for most cases.+- Always limit growth or shrinkage with the percentage (e.g. `300%`) as a guardrail.+- The container needs a definite inline size. `text-fit` never changes intrinsic size, so it does nothing on `fit-content`/`max-content` widths or content-sized flex/grid items.+- Trim the leading above the first and below the last line: see `precise-text-alignment` (via `npx -y modern-web-guidance@latest retrieve "precise-text-alignment"`).+- Keep `line-height` small, `1` or under, otherwise gaps between lines of different font-sizes become unwieldy.+- IMPORTANT: Note that computed `font-size` is unchanged, so `em` spacing does not scale.+- To avoid accidental over-emphasized orphans, apply `text-wrap: balance` or `text-wrap: pretty` if there are free lines.+++### Spacing++If all lines are forced, this produces more control over spacing:+- Apply `text-box: trim-both cap alphabetic` to each line block so its box hugs its own glyphs. It trims using the scaled metrics. See `precise-text-alignment` (via `npx -y modern-web-guidance@latest retrieve "precise-text-alignment"`) for more details.+- Space lines using Flexbox or Grid + `gap` on the heading, not `line-height`. Gaps are then uniform instead of growing with each line's font-size.++If some lines are free, do not use `text-box`: it only trims the first and last line, so the outer lines would hug the glyphs while interior gaps keep their leading. Let `line-height` govern all spacing.++## Visual design++- Lockups look best when there is significant variance in font sizes between lines. Avoid creating lockups from text with mostly uniform lines, as it will result in font sizes that are neither the same, nor sufficiently different, violating the design principle of _contrast_. You can ensure this by forcing short lines: wrap the words to emphasize in a block and let the rest wrap, i.e. a mixed lockup. This is especially important when combining with `text-wrap: balance`.+- Prefer combining this with `text-transform: uppercase` when used with Western scripts, as ascenders and descenders tend to create trapped space and/or overlap adjacent lines, which creates a less aesthetically pleasing result.+- When forcing short lines, pick words that would enhance the message if emphasized.+- **Limitation:** Growing text will also increase in visual weight and its strokes will be perceived as stronger. There is currently no way to counterbalance this e.g. by reducing `font-weight` for larger text, since there is no unit to use in a calculation, since the scaling does not affect font-relative units like `em`.++## Fallback strategies++### For `text-box`++Browser support for text-box: Limited availability.+Supported by: Chrome 133 (Feb 2025), Edge 133 (Feb 2025), and Safari 18.2 (Dec 2024).+Unsupported in: Firefox.++`text-box` needs no separate fallback: keep the small `line-height` on fixed lockups too. It is a no-op under `text-box` and keeps gaps tight where it is unsupported, at the cost of gaps that scale with each line's font-size.++### For `text-wrap: balance`++Baseline status for text-wrap: balance: Newly available. It's been Baseline since 2024-05-13.+Supported by: Chrome 114 (May 2023), Edge 114 (Jun 2023), Firefox 121 (Dec 2023), and Safari 17.5 (May 2024).++### For `text-fit`++Browser support for text-fit: Limited availability.+Supported by: Chrome 150 and Edge 150.+Unsupported in: Firefox and Safari.++Forced lines have a short, faithful fallback: measure each line at its base size and scale it by the ratio to the container, with the same cap.++```css+@supports not (text-fit: grow) {+ .lockup > span {+ /* Shrink-wrap each line so its width is the text width */+ width: fit-content;+ /* --text-fit-scale is measured by the script; the cap mirrors the text-fit percentage */+ font-size: min(var(--text-fit-scale, 1) * 1em, 300%);+ }+}+```++```js+if (!CSS.supports('text-fit', 'grow per-line-all')) {+ const fit = lockup => {+ const lines = [...lockup.querySelectorAll(':scope > span')];+ // Unscale first: on a refit, offsetWidth would otherwise include the previous scale+ for (const line of lines) line.style.removeProperty('--text-fit-scale');+ // MANDATORY: all reads, then all writes. Interleaving them (e.g. reading+ // lockup.clientWidth inside the write loop) forces one reflow per line.+ const scales = lines.map(line => lockup.clientWidth / line.offsetWidth);+ lines.forEach((line, i) => line.style.setProperty('--text-fit-scale', scales[i]));+ };+ // Refit on resize and font load+ for (const lockup of document.querySelectorAll('.lockup')) {+ new ResizeObserver(() => fit(lockup)).observe(lockup);+ }+}+```++Free lines have no faithful fallback (line breaks are unknown until layout): progressive enhancement to a balanced heading with a fluid base size such as `clamp(2rem, 1rem + 5cqi, 5rem)`. In a mixed lockup the script above still fits the forced lines; a wrapping block measures as wide as the container, so it keeps scale 1 and only gets the fluid base size.++If text fitting is critical, consider using a JS library (e.g. `fitty`), conditionally loaded only if `text-fit` is not supported.diff --git a/skills/modern-web-guidance/guides/visual-design/improve-text-layout-and-legibility.md b/skills/modern-web-guidance/guides/visual-design/improve-text-layout-and-legibility.mdindex 5a5098e..5d259bc 100644--- a/skills/modern-web-guidance/guides/visual-design/improve-text-layout-and-legibility.md+++ b/skills/modern-web-guidance/guides/visual-design/improve-text-layout-and-legibility.md@@ -68,7 +68,7 @@ p, blockquote, li, .pretty-text {Baseline status for text-wrap: balance: Newly available. It's been Baseline since 2024-05-13.Supported by: Chrome 114 (May 2023), Edge 114 (Jun 2023), Firefox 121 (Dec 2023), and Safari 17.5 (May 2024).-text-wrap: pretty has limited availability.+Browser support for text-wrap: pretty: Limited availability.Supported by: Chrome 117 (Sep 2023), Edge 117 (Sep 2023), and Safari 26 (Sep 2025).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/visual-design/interactive-content-in-3d-scenes.md b/skills/modern-web-guidance/guides/visual-design/interactive-content-in-3d-scenes.mdindex 89ca5c5..7f867b2 100644--- a/skills/modern-web-guidance/guides/visual-design/interactive-content-in-3d-scenes.md+++ b/skills/modern-web-guidance/guides/visual-design/interactive-content-in-3d-scenes.md@@ -95,12 +95,12 @@ requestAnimationFrame(render);canvas.onpaint = (event) => {if (event.changedElements && event.changedElements.length > 0) {- // Update the texture with texElementImage2D, and update the CSS transform as shown in step 6+ // Update the texture with texElementImage2D, and update the CSS transform as shown in step 5}};```-6. Update the CSS transform.+5. Update the CSS transform.The browser needs to map from the 3D coordinate space into the CSS coordinate space using a viewport transform. To facilitate this, do the following:@@ -148,7 +148,7 @@ if (canvas.getElementTransform) {}```-7. [Troubleshooting] If the developer is experiencing a mismatch in the DOM logical layout in 3D even after applying the CSS transform from step 5, check if the developer is experiencing the issue in Chromium 148 or earlier. If that's the case, check if `transform.is2D` is correctly set to false for a 3D DOMMatrix. If not, re-initialize the DOMMatrix which corrects `is2D` to be false before applying the transform to the target HTML element. This issue is fixed in Chromium 149+, and if the developer is experiencing it in newer Chromium versions, the is2D value is not the cause:+6. [Troubleshooting] If the developer is experiencing a mismatch in the DOM logical layout in 3D even after applying the CSS transform from step 5, check if the developer is experiencing the issue in Chromium 148 or earlier. If that's the case, check if `transform.is2D` is correctly set to false for a 3D DOMMatrix. If not, re-initialize the DOMMatrix which corrects `is2D` to be false before applying the transform to the target HTML element. This issue is fixed in Chromium 149+, and if the developer is experiencing it in newer Chromium versions, the is2D value is not the cause:```jsif (transform.is2D) {@@ -348,7 +348,7 @@ function animate() {- **MANDATORY**: Check browser support for the HTML-in-Canvas API before using it.- **MANDATORY**: When using WebGL or WebGPU, always add the `layoutsubtree` attribute to the `<canvas>` element.- **MANDATORY**: When using WebGL or WebGPU, use an `onpaint` event handler to render the HTML content to the canvas.-- **MANDATORY**: Use the `texElementImage2D` for WebGL, or `copyElementImageToTexture` for WebGPU methods to render the HTML content to the canvas.+- **MANDATORY**: When using WebGL or WebGPU, use `texElementImage2D` for WebGL, or `copyElementImageToTexture` for WebGPU, to render the HTML content to the canvas.- **MANDATORY**: When using WebGL or WebGPU, update the CSS transform of the HTML element to match the transform of the rendered content by setting the `style.transform` property of the HTML element.- **MANDATORY**: Observe the screen size and update the canvas size to match device pixels, for example, by using `ResizeObserver`.- **DO NOT** embed cross-origin content in a canvas, as it is not supported.diff --git a/skills/modern-web-guidance/guides/visual-design/precise-text-alignment.md b/skills/modern-web-guidance/guides/visual-design/precise-text-alignment.mdindex 3ce52d8..b45f5f2 100644--- a/skills/modern-web-guidance/guides/visual-design/precise-text-alignment.md+++ b/skills/modern-web-guidance/guides/visual-design/precise-text-alignment.md@@ -87,7 +87,7 @@ h1 {### Fallback strategies-text-box has limited availability.+Browser support for text-box: Limited availability.Supported by: Chrome 133 (Feb 2025), Edge 133 (Feb 2025), and Safari 18.2 (Dec 2024).Unsupported in: Firefox.diff --git a/skills/modern-web-guidance/guides/visual-design/typography.md b/skills/modern-web-guidance/guides/visual-design/typography.mdnew file mode 100644index 0000000..6f2d76a--- /dev/null+++ b/skills/modern-web-guidance/guides/visual-design/typography.md@@ -0,0 +1,38 @@+# Typography++## Overall best practices++- Use unitless numbers for `line-height` (e.g., `1.5`) to ensure relative scaling during font-size inheritance.+- Use `overflow-wrap: break-word` (or `anywhere`) to contain long URLs.+- **DON'T** use `px` for font-size. Prefer `rem` to honor the user's browser font-size preferences (root font size), or `em`/percentages for contextual sizing.++## Readability++- **Avoid long lines of text**: Cap paragraph blocks to a maximum of 80 characters width.+- **Avoid rivers of whitespace**: Avoid `text-align: justify` as it can make text harder to read. If you must use it, combine it with `hyphens: auto` to avoid excessive whitespace between words.+- **Don't use Ornate fonts**: Omit cursive typefaces for main reading content.+- **Don't rely on all-caps for emphasis**: Prefer bolding for visual emphasis, and use `<em>`/`<strong>` when the emphasis is semantic.+- **Limit emphasis overall**: Emphasis loses meaning when it's everywhere — apply it only where it changes how the content should be read.+- **Support user zoom preferences**: Allow users to resize text up to 200% without loss of content or functionality.++```css+body {+ line-height: 1.5;+ text-align: start; /* Supports LTR and RTL */+}+article {+ max-width: 80ch; /* Caps line length to ~80 characters for readability */+}+```++## Text wrapping++- Use `text-wrap: balance` for balanced headlines and headline-like content (e.g. `<th>`)+- Use `text-wrap: pretty` for long-form body text (paragraphs, blockquotes, etc.)+- Use `text-wrap: balance` or `text-wrap: pretty` deliberately, **DO NOT** apply it on `*` as it does have a performance cost.+- Avoid `text-wrap: balance` on elements with a visible box (backgrounds, borders, shadows, etc) as it does not change the container's width, it only affects how text wraps *within* that width. This can leave empty space at the end of the container, which is usually undesirable.++## Responsive Typography++- **DO** combine viewport-relative and font-relative units in `clamp()` for font sizes that scale with the viewport size while ensuring they stay within a desired range. For example, `clamp(2rem, 1rem + 5vw, 4rem)`. Adjust the proportion of viewport-relative and font-relative units to control how quickly the font-size changes.+- **DON'T** use `vw` alone for font-size without `clamp()`, as it can scale text too small or too large on extreme screens.diff --git a/skills/modern-web-guidance/guides/visual-design/visual-effects.md b/skills/modern-web-guidance/guides/visual-design/visual-effects.mdnew file mode 100644index 0000000..adc287d--- /dev/null+++ b/skills/modern-web-guidance/guides/visual-design/visual-effects.md@@ -0,0 +1,100 @@+# Visual effects++### Depth and texture++- Layer multiple shadows for realistic soft depth effects.+- Use `filter: drop-shadow()` instead of `box-shadow` for non-rectangular shapes or transparent PNGs.+- Use `mix-blend-mode` and `background-blend-mode` for lighting overlays (limit scope with `isolation: isolate`)++```css+.hero {+ background-image: url('texture.png'), linear-gradient(to bottom, #fff, #eee);+ background-blend-mode: soft-light;+}+```++### Gradients and `color-mix()`++Use `in oklch` or `in oklab` to explicitly specify the interpolation color space for gradients or `color-mix()`.+- `in oklch` preserves chroma better, but can more easily get out of device gamut, especially for bigger differences between colors+- `in oklab` stays in gamut more easily (assuming in-gamut endpoints) but can create washed out desaturated colors in the middle, especially when interpolating between opposite hues.+- *DON'T* use `in srgb` unless you have a specific reason to do so (e.g. you are building a color picker that needs to interpolate in srgb).++#### Fallback++Some pre-2024 browsers do not support gradient color interpolation space.+To support these browsers, use the token only when its usage is safe by defining a variable:++```css+:root {+ --in-oklab: ;+ --in-oklch: ;+}++@supports (linear-gradient(in oklab, white, black)) {+ :root {+ --in-oklab: in oklab;+ --in-oklch: in oklch;+ }+}+```++Then use like:++```css+.card {+ background: linear-gradient(to bottom var(--in-oklab), var(--accent-color), var(--darker));+}+```++- **Important:** If you use this technique, make sure there is always a non-empty gradient preamble without it, otherwise it will be a syntax error in older browsers.+- You do NOT need this for `color-mix()`. If a browser supports `color-mix()`, it also supports its `in <color-space>` argument.++### Patterns++Many patterns can be created via CSS gradients + hard stops, and these can be more flexible and performant than SVGs or external images as they can have access to CSS variables and lengths from the surrounding context.+You don't need to repeat the position twice — just use `0` or `0%` and gradient fixup will auto-adjust it.++Examples below.++Vertical stripes of `1em` width each:++```css+background: linear-gradient(to right, var(--color-1) 50%, var(--color-2) 0) 0 / 2em;+```++Diagonal stripes of `1em` width each:++```css+background: repeating-linear-gradient(-45deg, var(--color-1) 0 1em, var(--color-2) 0 2em);+```++Checkerboard pattern with `1em` squares:++```css+background: repeating-conic-gradient(var(--color-1) 0 25%, var(--color-2) 0 50%) 0 / 2em 2em;+```++Polka dot with `.5em` radius dots spaced `2em` apart (horizontally/vertically — multiply by `sqrt(2)` for diagonal distance):++```css+--distance: 2em;+--radius: .5em;+--polka: radial-gradient(circle, var(--color-1) var(--radius), transparent calc(var(--radius) + 1px));+background: var(--polka) 0 0, var(--polka) var(--distance) var(--distance) var(--color-2);+background-size: calc(var(--distance) * 2) calc(var(--distance) * 2);+```++Simple pie chart:++```css+.pie {+ --p: 80%;+ width: 60px;+ aspect-ratio: 1;+ border-radius: 50%;+ background: conic-gradient(var(--color-1) var(--p), transparent 0%) var(--color-2);+}+```++**Important:** When using gradients to render charts, ensure there is a textual fallback for screen readers. MANDATORY: You MUST provide a semantic data table as an accessible alternative, as detailed in `accessibility` (via `npx -y modern-web-guidance@latest retrieve "accessibility"`) under the alternate text and media guidelines.diff --git a/skills/modern-web-guidance/guides/webmcp/agentic-forms.md b/skills/modern-web-guidance/guides/webmcp/agentic-forms.mdindex 73307e4..472249c 100644--- a/skills/modern-web-guidance/guides/webmcp/agentic-forms.md+++ b/skills/modern-web-guidance/guides/webmcp/agentic-forms.md@@ -62,15 +62,22 @@ document.querySelector('form').addEventListener('submit', (event) => {## Lifecycle Events-The window emits events when agents start or stop interacting with a tool:+`document.modelContext` emits events when agents start or stop interacting with a tool: `toolactivated` fires when tool execution starts, and `toolcancel` fires when it is canceled.```javascript-window.addEventListener('toolactivated', ({ toolName }) => {- console.log(`Tool "${toolName}" was activated by the agent.`);+// Starting in Chrome 156, these events are dispatched on `document.modelContext`.+// Older versions dispatch them on `window`. Feature-detect the event handler+// property to pick the right target for backward compatibility.+const targetFor = (type, listener, options) =>+ (`on${type}` in (document.modelContext ?? {}) ? document.modelContext : window)+ .addEventListener(type, listener, options);++targetFor('toolactivated', ({ toolName }) => {+ console.log(`Tool "${toolName}" started execution.`);});-window.addEventListener('toolcancel', ({ toolName }) => {- console.log(`Tool "${toolName}" interaction was cancelled.`);+targetFor('toolcancel', ({ toolName }) => {+ console.log(`Tool "${toolName}" execution is cancelled.`);});```diff --git a/skills/modern-web-guidance/guides/webmcp/agentic-javascript-tools.md b/skills/modern-web-guidance/guides/webmcp/agentic-javascript-tools.mdindex 2aa145c..bf026e7 100644--- a/skills/modern-web-guidance/guides/webmcp/agentic-javascript-tools.md+++ b/skills/modern-web-guidance/guides/webmcp/agentic-javascript-tools.md@@ -115,6 +115,26 @@ execute(input) {}```+### Handling errors in `execute`++When `execute` throws (or returns a rejected promise), the agent receives only a generic execution failure. The error message is not forwarded to the agent. If your tool encounters an actionable or recoverable error (such as invalid input, missing items, or a failed HTTP status), **DO NOT** `throw new Error(...)`. Instead, return a structured error payload via the tool's normal return value so the AI agent receives the diagnostic details and can self-correct or retry:++```javascript+execute({ itemName }) {+ const item = menuItems.find((entry) => entry.name.toLowerCase() === itemName.toLowerCase());+ if (!item) {+ // Return the error as a value instead of throwing, so the agent receives the message:+ return {+ error: `Menu item "${itemName}" not found.`,+ availableItems: menuItems.map((entry) => entry.name),+ };+ }+ return item;+}+```++Only re-throw when the execution was cancelled (`signal.aborted` is `true`).+### Cancelling in-flight executionsCancellation is initiated by the user or the agent. **MANDATORY:** Any tool that performs network requests or other long-running async work MUST honor `signal`, otherwise cancelled executions keep consuming resources and can write stale data into the UI after the agent has moved on.@@ -144,14 +164,22 @@ await document.modelContext.registerTool({try {// Passing `signal` aborts the network request the moment execution is cancelled.const response = await fetch(url, { priority, signal });+ if (!response.ok) {+ output.textContent = "";+ return { error: `Request failed with status ${response.status}` };+ }const text = await response.text();output.textContent = text;return text;} catch (err) {// Roll back the UI state this execution set, so a cancelled run leaves no trace.output.textContent = "";- // Re-throw, including AbortError: it carries the caller's cancellation reason.- throw err;+ if (signal.aborted) {+ // The execution was cancelled: re-throw instead of returning an error value.+ throw err;+ }+ // Return other errors as a value instead of throwing, so the agent receives the message.+ return { error: err instanceof Error ? err.message : String(err) };}},annotations: { readOnlyHint: true }@@ -313,7 +341,7 @@ export function createInventoryTool(inventoryManager) {* **exposedTo**: (Optional) An array of secure origin strings controlling which documents in the document tree are allowed to discover and execute the tool across frame boundaries.* **Tool Discovery Options (`ModelContextGetToolOptions`)**:* **fromOrigins**: (Optional) An array of secure origin strings to query in accessible frames. Calling `getTools()` without `fromOrigins` queries only same-origin documents.-* **Return Format**: The `execute` function can return any value (object, array, string, number, boolean). Select a structure that best serves your specific use case while ensuring the content is optimized for the LLM to process. The output may encompass raw data, specific error logs, or direct instructions to influence the agent's next action.+* **Return Format**: The `execute` function can return any JSON-serializable value (object, array, string, number, boolean). The message of an exception thrown from `execute` is not forwarded to the agent, so return actionable errors as structured error payloads (e.g. `{ error: "..." }`) via the tool's return value so the agent can read and act on them.* **Secure Context**: WebMCP requires HTTPS. All origins in `exposedTo` and `fromOrigins` must also be potentially trustworthy.* **Deprecated/Removed**: `navigator.modelContext` (deprecated in Chromium 150), `unregisterTool()`, `provideContext()`, and `clearContext()` are no longer supported.