Keep your coding agent up to date with the latest web best practices
Release v0.0.194
github-actions[bot]b31dc0a43ff5
diff --git a/.agents/plugins/marketplace.json b/.agents/plugins/marketplace.jsonindex 59deac0..1af2480 100644--- a/.agents/plugins/marketplace.json+++ b/.agents/plugins/marketplace.json@@ -15,7 +15,7 @@"authentication": "ON_INSTALL"},"category": "Developer Tools",- "version": "0.0.193"+ "version": "0.0.194"}]}diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.jsonindex 5313d8f..b97ec48 100644--- a/.claude-plugin/marketplace.json+++ b/.claude-plugin/marketplace.json@@ -1,5 +1,6 @@{"name": "googlechrome",+ "description": "Modern web development guidance for AI coding agents.","owner": {"name": "Google Chrome"},@@ -8,7 +9,7 @@"name": "modern-web-guidance","source": "./","description": "Keep your coding agent up to date with the latest web best practices",- "version": "0.0.193"+ "version": "0.0.194"}]}diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonindex 5ef3173..81b3bb6 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.193",+ "version": "0.0.194","author": {"name": "Google Chrome"}diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.jsonindex 792f28c..7590728 100644--- a/.codex-plugin/plugin.json+++ b/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "modern-web-guidance",- "version": "0.0.193",+ "version": "0.0.194","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 07a8c4f..c20f77f 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.193",+ "version": "0.0.194","author": {"name": "Google Chrome"}diff --git a/.github/plugin/plugin.json b/.github/plugin/plugin.jsonindex 07a8c4f..c20f77f 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.193",+ "version": "0.0.194","author": {"name": "Google Chrome"}diff --git a/.grok-plugin/marketplace.json b/.grok-plugin/marketplace.jsonindex 5313d8f..b71924a 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.193"+ "version": "0.0.194"}]}diff --git a/README.md b/README.mdindex 9d9b7c3..fc19a8f 100644--- a/README.md+++ b/README.md@@ -4,7 +4,7 @@# Modern Web Guidance-Modern Web Guidance is a set of skills that embed web platform expertise, best practices, and browser compatibility data directly into your coding agents. It helps to steer your coding agents away from legacy patterns, and instead toward solutions that harness the power and capabilities of the modern web platform.+[Modern Web Guidance](https://developer.chrome.com/docs/modern-web-guidance) is a set of skills that embed web platform expertise, best practices, and browser compatibility data directly into your coding agents. It helps to steer your coding agents away from legacy patterns, and instead toward solutions that harness the power and capabilities of the modern web platform.*Supported by the Google Chrome team, the Microsoft Edge team, and the web development community.*@@ -85,93 +85,99 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro#### The full list<details>-<summary><strong>195 modern web features</strong></summary>+<summary><strong>212 modern web features</strong></summary>-### CSS & Layout (108 features)+### CSS & Layout (120 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 (size)](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)+| [::backdrop](https://web-platform-dx.github.io/web-features-explorer/features/backdrop/) | [Content](https://web-platform-dx.github.io/web-features-explorer/features/content/) | [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-visibility](https://web-platform-dx.github.io/web-features-explorer/features/content-visibility/) | [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/) | [contrast-color()](https://web-platform-dx.github.io/web-features-explorer/features/contrast-color/) | [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/) | [Cross-document view transitions](https://web-platform-dx.github.io/web-features-explorer/features/cross-document-view-transitions/) | [prefers-contrast media query](https://web-platform-dx.github.io/web-features-explorer/features/prefers-contrast/) |+| [:dir()](https://web-platform-dx.github.io/web-features-explorer/features/dir-pseudo/) | [currentColor](https://web-platform-dx.github.io/web-features-explorer/features/currentcolor/) | [prefers-reduced-motion media query](https://web-platform-dx.github.io/web-features-explorer/features/prefers-reduced-motion/) |+| [: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/) | [progress()](https://web-platform-dx.github.io/web-features-explorer/features/progress-function/) |+| [:host-context()](https://web-platform-dx.github.io/web-features-explorer/features/host-context/) | [Custom properties](https://web-platform-dx.github.io/web-features-explorer/features/custom-properties/) | [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/) | [display animation](https://web-platform-dx.github.io/web-features-explorer/features/display-animation/) | [rem](https://web-platform-dx.github.io/web-features-explorer/features/rem/) |+| [:modal](https://web-platform-dx.github.io/web-features-explorer/features/modal/) | [em unit](https://web-platform-dx.github.io/web-features-explorer/features/em-unit/) | [resize (CSS property)](https://web-platform-dx.github.io/web-features-explorer/features/resize/) |+| [:not()](https://web-platform-dx.github.io/web-features-explorer/features/not/) | [field-sizing](https://web-platform-dx.github.io/web-features-explorer/features/field-sizing/) | [revert](https://web-platform-dx.github.io/web-features-explorer/features/revert-value/) |+| [:nth-child() of <selector>](https://web-platform-dx.github.io/web-features-explorer/features/nth-child-of/) | [filter](https://web-platform-dx.github.io/web-features-explorer/features/filter/) | [Scroll marker target pseudo-classes](https://web-platform-dx.github.io/web-features-explorer/features/scroll-marker-targets/) |+| [:placeholder-shown](https://web-platform-dx.github.io/web-features-explorer/features/placeholder-shown/) | [flex-wrap: balance](https://web-platform-dx.github.io/web-features-explorer/features/flexbox-flex-wrap-balance/) | [Scroll method promises](https://web-platform-dx.github.io/web-features-explorer/features/scroll-promises/) |+| [:user-valid and :user-invalid](https://web-platform-dx.github.io/web-features-explorer/features/user-pseudos/) | [Flexbox](https://web-platform-dx.github.io/web-features-explorer/features/flexbox/) | [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/) | [font-size](https://web-platform-dx.github.io/web-features-explorer/features/font-size/) | [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-adjust](https://web-platform-dx.github.io/web-features-explorer/features/font-size-adjust/) | [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/) | [Forced colors](https://web-platform-dx.github.io/web-features-explorer/features/forced-colors/) | [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/) | [Gradient interpolation](https://web-platform-dx.github.io/web-features-explorer/features/gradient-interpolation/) | [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/) | [Gradients](https://web-platform-dx.github.io/web-features-explorer/features/gradients/) | [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/) | [Grid](https://web-platform-dx.github.io/web-features-explorer/features/grid/) | [scrollbar-gutter](https://web-platform-dx.github.io/web-features-explorer/features/scrollbar-gutter/) |+| [Active view transition](https://web-platform-dx.github.io/web-features-explorer/features/active-view-transition/) | [Grid lanes](https://web-platform-dx.github.io/web-features-explorer/features/grid-lanes/) | [scrollbar-width](https://web-platform-dx.github.io/web-features-explorer/features/scrollbar-width/) |+| [Alt text for generated content](https://web-platform-dx.github.io/web-features-explorer/features/alt-text-generated-content/) | [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/) |+| [Anchor position container queries](https://web-platform-dx.github.io/web-features-explorer/features/container-anchor-position-queries/) | [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 positioning](https://web-platform-dx.github.io/web-features-explorer/features/anchor-positioning/) | [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/) |+| [Animations (CSS)](https://web-platform-dx.github.io/web-features-explorer/features/animations-css/) | [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/) |+| [appearance](https://web-platform-dx.github.io/web-features-explorer/features/appearance/) | [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/) |+| [aspect-ratio](https://web-platform-dx.github.io/web-features-explorer/features/aspect-ratio/) | [isolation](https://web-platform-dx.github.io/web-features-explorer/features/isolation/) | [Subgrid](https://web-platform-dx.github.io/web-features-explorer/features/subgrid/) |+| [at-rule()](https://web-platform-dx.github.io/web-features-explorer/features/supports-at-rule/) | [Lab and LCH](https://web-platform-dx.github.io/web-features-explorer/features/lab/) | [System colors](https://web-platform-dx.github.io/web-features-explorer/features/system-color/) |+| [attr()](https://web-platform-dx.github.io/web-features-explorer/features/attr/) | [light-dark()](https://web-platform-dx.github.io/web-features-explorer/features/light-dark/) | [text-box](https://web-platform-dx.github.io/web-features-explorer/features/text-box/) |+| [background-blend-mode](https://web-platform-dx.github.io/web-features-explorer/features/background-blend-mode/) | [line-clamp](https://web-platform-dx.github.io/web-features-explorer/features/line-clamp/) | [text-wrap](https://web-platform-dx.github.io/web-features-explorer/features/text-wrap/) |+| [border-radius](https://web-platform-dx.github.io/web-features-explorer/features/border-radius/) | [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/) |+| [box-shadow](https://web-platform-dx.github.io/web-features-explorer/features/box-shadow/) | [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/) |+| [calc-size()](https://web-platform-dx.github.io/web-features-explorer/features/calc-size/) | [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/) |+| [Cascade layers](https://web-platform-dx.github.io/web-features-explorer/features/cascade-layers/) | [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/) |+| [clip-path](https://web-platform-dx.github.io/web-features-explorer/features/clip-path/) | [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/) |+| [color-mix()](https://web-platform-dx.github.io/web-features-explorer/features/color-mix/) | [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-scheme](https://web-platform-dx.github.io/web-features-explorer/features/color-scheme/) | [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/) |+| [Conic gradients](https://web-platform-dx.github.io/web-features-explorer/features/conic-gradients/) | [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/) |+| [Container queries (size)](https://web-platform-dx.github.io/web-features-explorer/features/container-queries/) | [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 scroll-state queries](https://web-platform-dx.github.io/web-features-explorer/features/container-scroll-state-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 style queries](https://web-platform-dx.github.io/web-features-explorer/features/container-style-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 (34 features)| | | || :--- | :--- | :--- |-| [: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/) |-| [<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 (56 features)+| [:autofill](https://web-platform-dx.github.io/web-features-explorer/features/autofill/) | [<video>](https://web-platform-dx.github.io/web-features-explorer/features/video/) | [inert](https://web-platform-dx.github.io/web-features-explorer/features/inert/) |+| [:indeterminate](https://web-platform-dx.github.io/web-features-explorer/features/indeterminate/) | [Autonomous custom elements](https://web-platform-dx.github.io/web-features-explorer/features/autonomous-custom-elements/) | [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/) | [blocking="render"](https://web-platform-dx.github.io/web-features-explorer/features/blocking-render/) | [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/) | [Customizable <select>](https://web-platform-dx.github.io/web-features-explorer/features/customizable-select/) | [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/) | [Declarative shadow DOM](https://web-platform-dx.github.io/web-features-explorer/features/declarative-shadow-dom/) | [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/) | [Email, telephone, and URL <input> types](https://web-platform-dx.github.io/web-features-explorer/features/input-email-tel-url/) | [MutationObserver](https://web-platform-dx.github.io/web-features-explorer/features/mutationobserver/) |+| [<input type="checkbox" switch>](https://web-platform-dx.github.io/web-features-explorer/features/switch-control/) | [Fetch priority](https://web-platform-dx.github.io/web-features-explorer/features/fetch-priority/) | [Mutually exclusive <details> elements](https://web-platform-dx.github.io/web-features-explorer/features/details-name/) |+| [<input type="range">](https://web-platform-dx.github.io/web-features-explorer/features/input-range/) | [Form-associated custom elements](https://web-platform-dx.github.io/web-features-explorer/features/form-associated-custom-elements/) | [Popover](https://web-platform-dx.github.io/web-features-explorer/features/popover/) |+| [<link rel="expect">](https://web-platform-dx.github.io/web-features-explorer/features/link-rel-expect/) | [hidden="until-found"](https://web-platform-dx.github.io/web-features-explorer/features/hidden-until-found/) | [popover="hint"](https://web-platform-dx.github.io/web-features-explorer/features/popover-hint/) |+| [<link rel="preload">](https://web-platform-dx.github.io/web-features-explorer/features/link-rel-preload/) | [HTML in canvas](https://web-platform-dx.github.io/web-features-explorer/features/canvas-html/) | [Shadow DOM](https://web-platform-dx.github.io/web-features-explorer/features/shadow-dom/) |+| [<progress>](https://web-platform-dx.github.io/web-features-explorer/features/progress/) | [HTML setter methods](https://web-platform-dx.github.io/web-features-explorer/features/html-setters/) | |+| [<slot>](https://web-platform-dx.github.io/web-features-explorer/features/slot/) | [HTML streaming setters](https://web-platform-dx.github.io/web-features-explorer/features/html-streaming-setters/) | |++### JavaScript & APIs (58 features)| | | || :--- | :--- | :--- |-| [<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/) |-| [Connection allowlists](https://web-platform-dx.github.io/web-features-explorer/features/connection-allowlists/) | [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/) |-| [corner-shape](https://web-platform-dx.github.io/web-features-explorer/features/corner-shape/) | [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/) |-| [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/) | [text-fit](https://web-platform-dx.github.io/web-features-explorer/features/text-fit/) |-| [email-verification](https://web-platform-dx.github.io/web-features-explorer/features/tmp-email-verification/) | [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/) |-| [enterkeyhint](https://web-platform-dx.github.io/web-features-explorer/features/enterkeyhint/) | [Navigation API](https://web-platform-dx.github.io/web-features-explorer/features/navigation/) | [touch-action](https://web-platform-dx.github.io/web-features-explorer/features/touch-action/) |-| [Event timing performance entries](https://web-platform-dx.github.io/web-features-explorer/features/event-timing/) | [Origin](https://web-platform-dx.github.io/web-features-explorer/features/origin/) | [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/) | [Pointer Events](https://web-platform-dx.github.io/web-features-explorer/features/pointer-events-api/) | [Web authentication signal methods](https://web-platform-dx.github.io/web-features-explorer/features/webauthn-signals/) |-| [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/) | [WebAssembly](https://web-platform-dx.github.io/web-features-explorer/features/wasm/) |-| [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/) | [WebOTP](https://web-platform-dx.github.io/web-features-explorer/features/web-otp/) |-| [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/) | |+| [<meta name="text-scale">](https://web-platform-dx.github.io/web-features-explorer/features/meta-text-scale/) | [Intl.DurationFormat](https://web-platform-dx.github.io/web-features-explorer/features/intl-duration-format/) | [Soft navigation performance entries](https://web-platform-dx.github.io/web-features-explorer/features/soft-navigations/) |+| [<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/) | [Summarizer](https://web-platform-dx.github.io/web-features-explorer/features/summarizer/) |+| [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/) | [SVG](https://web-platform-dx.github.io/web-features-explorer/features/svg/) |+| [autocorrect](https://web-platform-dx.github.io/web-features-explorer/features/autocorrect/) | [Lazy-loading images and iframes](https://web-platform-dx.github.io/web-features-explorer/features/loading-lazy/) | [Temporal](https://web-platform-dx.github.io/web-features-explorer/features/temporal/) |+| [Connection allowlists](https://web-platform-dx.github.io/web-features-explorer/features/connection-allowlists/) | [light-dark() image values](https://web-platform-dx.github.io/web-features-explorer/features/light-dark-image/) | [text-fit](https://web-platform-dx.github.io/web-features-explorer/features/text-fit/) |+| [corner-shape](https://web-platform-dx.github.io/web-features-explorer/features/corner-shape/) | [Local network access](https://web-platform-dx.github.io/web-features-explorer/features/local-network-access/) | [Top-level await](https://web-platform-dx.github.io/web-features-explorer/features/top-level-await/) |+| [document.modelContext](https://web-platform-dx.github.io/web-features-explorer/features/document-modelcontext/) | [Long animation frames performance entries](https://web-platform-dx.github.io/web-features-explorer/features/long-animation-frames/) | [touch-action](https://web-platform-dx.github.io/web-features-explorer/features/touch-action/) |+| [email-verification](https://web-platform-dx.github.io/web-features-explorer/features/tmp-email-verification/) | [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/) |+| [enterkeyhint](https://web-platform-dx.github.io/web-features-explorer/features/enterkeyhint/) | [Origin](https://web-platform-dx.github.io/web-features-explorer/features/origin/) | [Trusted types](https://web-platform-dx.github.io/web-features-explorer/features/trusted-types/) |+| [Event timing performance entries](https://web-platform-dx.github.io/web-features-explorer/features/event-timing/) | [Page visibility](https://web-platform-dx.github.io/web-features-explorer/features/page-visibility/) | [User agent client hints](https://web-platform-dx.github.io/web-features-explorer/features/ua-client-hints/) |+| [Federated credential management](https://web-platform-dx.github.io/web-features-explorer/features/fedcm/) | [Page visibility state performance entries](https://web-platform-dx.github.io/web-features-explorer/features/page-visibility-state/) | [Web app origin migration](https://web-platform-dx.github.io/web-features-explorer/features/app-migration/) |+| [Fetch](https://web-platform-dx.github.io/web-features-explorer/features/fetch/) | [Partitioned cookies](https://web-platform-dx.github.io/web-features-explorer/features/partitioned-cookies/) | [Web authentication](https://web-platform-dx.github.io/web-features-explorer/features/webauthn/) |+| [fetchLater](https://web-platform-dx.github.io/web-features-explorer/features/fetchlater/) | [Permissions policy](https://web-platform-dx.github.io/web-features-explorer/features/permissions-policy/) | [Web authentication signal methods](https://web-platform-dx.github.io/web-features-explorer/features/webauthn-signals/) |+| [Form-associated WebMCP attributes](https://web-platform-dx.github.io/web-features-explorer/features/declarative-webmcp/) | [Pointer Events](https://web-platform-dx.github.io/web-features-explorer/features/pointer-events-api/) | [Web Cryptography](https://web-platform-dx.github.io/web-features-explorer/features/web-cryptography/) |+| [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/) | [WebAssembly](https://web-platform-dx.github.io/web-features-explorer/features/wasm/) |+| [image()](https://web-platform-dx.github.io/web-features-explorer/features/image-function/) | [Resize observer](https://web-platform-dx.github.io/web-features-explorer/features/resize-observer/) | [webcrypto-modern-algos](https://web-platform-dx.github.io/web-features-explorer/features/tmp-webcrypto-modern-algos/) |+| [inputmode](https://web-platform-dx.github.io/web-features-explorer/features/inputmode/) | [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/) |+| [Interaction contentful paint performance entries](https://web-platform-dx.github.io/web-features-explorer/features/interaction-contentful-paint/) | [Scheduler API](https://web-platform-dx.github.io/web-features-explorer/features/scheduler/) | |+| [Intersection observer](https://web-platform-dx.github.io/web-features-explorer/features/intersection-observer/) | [Small, large, and dynamic viewport units](https://web-platform-dx.github.io/web-features-explorer/features/viewport-unit-variants/) | |</details><details>-<summary><strong>170 real-world developer use cases</strong></summary>+<summary><strong>180 real-world developer use cases</strong></summary><h3>accessibility</h3>@@ -194,6 +200,7 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro- **[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.+- **[css-layout](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/css-layout.md)**: Modern CSS layouts such as flexbox, grid, subgrid, container queries, anchor positioning, and intrinsic sizing. Use this skill when architecting responsive UI components or page layouts.- **[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@@ -222,7 +229,9 @@ _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.+- **[slider](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/forms/slider.md)**: Style a native range slider with custom track, thumb, fill, and focus states while preserving native functionality and accessibility.- **[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.+- **[switch](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/forms/switch.md)**: Build an accessible switch with the native HTML switch attribute, falling back to a styled checkbox when not supported.- **[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>@@ -285,6 +294,8 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro<h3>security</h3>+- **[client-side-encryption](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/security/client-side-encryption.md)**: Establish shared secrets using public-key encapsulation or key agreement—including hybrid and post-quantum protection—and encrypt sensitive data in the browser with authenticated encryption.+- **[digital-signatures](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/security/digital-signatures.md)**: Sign and verify messages, tokens, or artifacts in the browser using classical or quantum-resistant (post-quantum) asymmetric keys to ensure data integrity and authenticity.- **[local-network-access](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/security/local-network-access.md)**: Access resources on a user's local network or loopback interface from a public web application.- **[passkey-authentication](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/security/passkey-authentication.md)**: Authenticate a returning user with a passkey for primary sign-in.- **[passkey-conditional-create](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/security/passkey-conditional-create.md)**: Silently register a passkey for an existing user after a successful password login.@@ -294,7 +305,7 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro- **[passkeys](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/security/passkeys.md)**: Comprehensive orientation and cross-cutting principles for implementing WebAuthn and Passkeys in web applications. Use this guide when handling passkey registration, authentication, management, or reauthentication.- **[restrict-outbound-connections](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/security/restrict-outbound-connections.md)**: Restrict a page or worker to communicating only with an explicit allowlist of network endpoints to prevent unauthorized third-party requests and client-side data exfiltration.- **[sanitize-untrusted-html](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/security/sanitize-untrusted-html.md)**: Safely parse and display untrusted HTML content from user input by removing unsafe elements and attributes.-- **[trusted-types](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/security/trusted-types.md)**: Help prevent DOM-based XSS attacks by ensuring all untrusted content is sanitized before being inserted into the page.+- **[trusted-types](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/security/trusted-types.md)**: Help prevent DOM-based XSS attacks by locking down dangerous DOM sinks so they reject raw strings and only accept policy-validated HTML.- **[validate-origins](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/security/validate-origins.md)**: Compare and validate web origins and sites safely across cross-document messages and URLs without error-prone string parsing.- **[verify-email-ownership](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/security/verify-email-ownership.md)**: Verify that a user owns an email address during account creation, sign-in, or recovery without sending a one-time passcode or magic link email.@@ -337,7 +348,9 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro- **[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.- **[physics-based-easing](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/physics-based-easing.md)**: Create custom, physics-based animation and transition effects, like bounce and spring, that feel more natural and engaging than traditional easing curves.- **[platform-controls-dismiss-dialog](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/platform-controls-dismiss-dialog.md)**: Create a modal dialog that can be closed via standard platform-specific user actions, such as pressing the `Esc` key on desktop platforms, or a "back" or "dismiss" gesture on mobile platforms+- **[prevent-page-scroll-under-modal-dialog](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/prevent-page-scroll-under-modal-dialog.md)**: Prevent the underlying page from scrolling while a modal dialog is open.- **[same-document-transitions](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/same-document-transitions.md)**: Visually connect persisting elements across different page states or navigations in a Single Page Application (SPA) (e.g. expanding a product thumbnail into a full-bleed hero image) by smoothly morphing their size, position, or other styling properties.+- **[scroll-completion-effects](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/scroll-completion-effects.md)**: Trigger visual effects, animations, or focus changes on a target element only after a smooth programmatic scroll to that element has finished.- **[scroll-entry-exit-effects](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/scroll-entry-exit-effects.md)**: Create fade-in, scale-up, or other complex reveal-type effects on elements as they enter and exit the scrollport (or viewport) while the user is scrolling.- **[scroll-snap-realtime-feedback](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/scroll-snap-realtime-feedback.md)**: Provide real-time visual feedback in linked UI elements while a user scrolls through snap-aligned content, before the scroll gesture completes.- **[scroll-snap-state-sync](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/scroll-snap-state-sync.md)**: Synchronize navigation indicators, linked content panels, and analytics tracking with the actively snapped item in a scrollable container.@@ -346,10 +359,13 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro- **[search-hidden-content](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/search-hidden-content.md)**: Hide content from view using patterns such as accordions, tabs, and "Read more" sections, while ensuring the hidden text reveals itself during native "Find in page" searches, allows search engine indexing, supports URL fragment deep links, and maintains ARIA accessibility.- **[spatial-navigation](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/spatial-navigation.md)**: Implement accessible spatial navigation using arrow keys that works correctly in different layout modes (grid etc)- **[swipe-to-remove](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/swipe-to-remove.md)**: Let users act on items in a list (remove, archive, mark as read, etc.) with a horizontal swipe gesture, so they can process entries quickly without tapping a separate control.+- **[swipe-to-reveal](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-behaviors/swipe-to-reveal.md)**: Let users swipe horizontally on a list item or content pane to reveal contextual action buttons or a side menu without automatically triggering an action.<h3>ui-components</h3>+- **[checkbox](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-components/checkbox.md)**: Style checkboxes, including custom icons, layout, colors, check/uncheck animations, while preserving native functionality and accessibility.- **[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.+- **[hovercard](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-components/hovercard.md)**: Build a hovercard component that displays an interactive structured preview of the page a certain type of link (e.g. a user profile) will navigate to when hovered over.- **[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 overlaid 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.@@ -515,16 +531,15 @@ We developed a robust eval harness to ensure that the content is **empirically p<!-- INJECT_EVAL_RESULTS_START -->| Date | Agent + Model | Tasks / Assertions | Unguided → Guided (Uplift) || :--- | :--- | :---: | :---: |-| 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_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_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**) |-| Sep 4 | claude_code (sonnet-5) | 132 / 1124 | 54% → 89% (**+35pp**) |+| Oct 9 | codex_cli (gpt-6.1-sol) | 153 / 1284 | 58% → 77% (**+19pp**) |+| Oct 9 | claude_code (sonnet-5-5) | 153 / 1297 | 59% → 87% (**+28pp**) |+| Oct 9 | antigravity_cli (gemini-3.8-flash) | 153 / 1062 | 65% → 90% (**+25pp**) |+| Oct 7 | codex_cli (gpt-6.1-sol) | 147 / 1251 | 56% → 75% (**+19pp**) |+| Oct 7 | claude_code (sonnet-5-5) | 147 / 1251 | 56% → 84% (**+28pp**) |+| Oct 7 | antigravity_cli (gemini-3.8-flash) | 147 / 1195 | 64% → 89% (**+25pp**) |+| Oct 6 | claude_code (opus-5-5) | 145 / 1236 | 61% → 89% (**+28pp**) |+| Oct 6 | codex_cli (gpt-6.1-sol) | 145 / 1236 | 57% → 77% (**+20pp**) |+| Oct 6 | antigravity_cli (gemini-3.8-flash) | 145 / 1057 | 62% → 88% (**+26pp**) |<!-- INJECT_EVAL_RESULTS_END -->@@ -541,7 +556,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, 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).+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/src/cli/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 5ef3173..81b3bb6 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.193",+ "version": "0.0.194","author": {"name": "Google Chrome"}diff --git a/kimi.plugin.json b/kimi.plugin.jsonindex 4a8cc01..6af6237 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.193",+ "version": "0.0.194","author": {"name": "Google Chrome"},diff --git a/package.json b/package.jsonindex a3e8224..a09ddf6 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.193",+ "version": "0.0.194","publisher": "GoogleChrome","repository": {"url": "https://github.com/GoogleChrome/modern-web-guidance-src"diff --git a/skills/modern-web-guidance/SKILL.md b/skills/modern-web-guidance/SKILL.mdindex 9660c48..e3ad5dd 100644--- a/skills/modern-web-guidance/SKILL.md+++ b/skills/modern-web-guidance/SKILL.md@@ -35,7 +35,7 @@ Must use this skill:Search with an action-oriented query summarizing what you want to achieve using the `search` command. Run `modern-web-guidance` directly with `npx`.```sh-npx -y modern-web-guidance@latest search "<query>" --skill-version 2026_09_04-7de96777+npx -y modern-web-guidance@latest search "<query>" --skill-version 2026_10_12-dacb5911```**Example Output**:@@ -88,6 +88,14 @@ When generating or modifying code, cross-check the implementation against the re- **Applicable Guidance & Fallbacks**: Ensure the relevant modern patterns and necessary fallback strategies from the guide are correctly applied, without forcing unrequested features.- **Task Fulfillment**: Confirm that the implementation fully satisfies the user's request.+### Step 4. Disclose Skill Usage++When you consult `modern-web-guidance` for a task, end the response where you deliver those changes with a `### Modern Web Guidance` section:+- **When retrieved guides shaped your code**: Write **one** bullet (1–2 sentences, ≤75 words) per newly applied `<id>` in first-person voice explaining the non-obvious implementation choices, CSS/API overrides, or fallbacks `<id>` required and the pitfall it prevented, anchored by a short verbatim quote of that specific rule or gotcha (never the guide's intro overview):+ `- **\`<id>\`**: <Non-obvious APIs, overrides, or fallbacks applied and the pitfall prevented> ("<short verbatim quote of the specific rule or gotcha>").`+ - **Never** guess `<id>`s or quotes from memory after context compaction (re-run `search`/`retrieve` if needed), and credit **only** guide-backed changes from the current turn.+- **When searched/listed in this turn but zero guides applied**: Write one first-person sentence naming which topics or guides you checked in `modern-web-guidance` and why none applied (omit if any guide applied).+## Using npx / pnpx- Prefer `pnpx` over `npx` if `pnpm` is available (note: `pnpx` does not use the `-y` flag).diff --git a/skills/modern-web-guidance/guides/css/atrule-support-conditionals.md b/skills/modern-web-guidance/guides/css/atrule-support-conditionals.mdindex 9d17dbe..10b72ed 100644--- a/skills/modern-web-guidance/guides/css/atrule-support-conditionals.md+++ b/skills/modern-web-guidance/guides/css/atrule-support-conditionals.md@@ -138,8 +138,8 @@ IMPORTANT:## Fallback strategiesBrowser support for at-rule(): Limited availability.-Supported by: Chrome 148 (May 2026) and Edge 148 (May 2026).-Unsupported in: Firefox and Safari.+Supported by: Chrome 148 (May 2026), Edge 148 (May 2026), and Firefox 157.+Unsupported in: 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.diff --git a/skills/modern-web-guidance/guides/css/css-layout.md b/skills/modern-web-guidance/guides/css/css-layout.mdindex 23533ef..e562b08 100644--- a/skills/modern-web-guidance/guides/css/css-layout.md+++ b/skills/modern-web-guidance/guides/css/css-layout.md@@ -49,12 +49,17 @@ body.centered { display: grid; place-content: center; min-block-size: 100dvb; }## 2 Flexbox+Browser support for flex-wrap: balance: Limited availability.+Supported by: Chrome 150 (Jun 2026) and Edge 150 (Jul 2026).+Unsupported in: Firefox and Safari.+One-dimensional layout — items flow along a single **main** axis with alignment on the **cross** axis. Reach for it for navbars, toolbars, item rows, and any single-row-or-column distribution.**Do:**- Establish a context with `display: flex` and set the main axis with `flex-direction` (`row` default).- Use `flex-wrap: wrap` whenever overflow is a possibility — `nowrap` without `overflow: auto/hidden` will spill on narrow viewports.+- Layer `flex-wrap: balance` after `flex-wrap: wrap` on wrapped rows of compact items (such as tag clouds, filter pills, button groups, or navigation links) to distribute items evenly across lines and prevent a single orphaned item on the final row; browsers without support fall back to `wrap`.- Use the `flex` shorthand `<grow> <shrink> <basis>` (e.g., `flex: 1 1 250px`) on items rather than setting `flex-grow`/`flex-shrink`/`flex-basis` individually.- Use `gap` (or the `row-gap`/`column-gap` longhand) for spacing between items instead of child margins.- Prefix positional alignment with `safe` (e.g., `align-items: safe center`) so focusable content isn't clipped when the container is narrower than its content.@@ -77,6 +82,7 @@ One-dimensional layout — items flow along a single **main** axis with alignmen.card-item { flex: 1 1 250px; } /* grow, shrink, basis */.card-item-action { margin-inline-start: auto; } /* Push to main-axis end. */.toolbar { display: flex; align-items: safe center; }+.tag-list { display: flex; flex-wrap: wrap; flex-wrap: balance; gap: 0.5rem; }```## 3 Grid and subgrid@@ -169,7 +175,7 @@ Query the size (or computed style) of an ancestor container rather than the view**Do:**- Establish a containment context with `container-type: inline-size` (width-only queries) or `container-type: size` (both axes) on a wrapper before its descendants can be queried.-- Name containers with `container-name` (or the `container` shorthand: `container: inline-size card`) when nested contexts could collide.+- Name containers with `container-name` (or the `container` shorthand: `container: card / inline-size`) when nested contexts could collide.- Include container query units in calculating fluid type and spacing: `cqi`/`cqb` (logical inline/block), `cqw`/`cqh` (physical), `cqmin`/`cqmax`.- Give the container a definite `block-size` whenever `container-type: size` is used — without one, descendants collapse because size containment forces the container to ignore its content.@@ -183,7 +189,7 @@ Query the size (or computed style) of an ancestor container rather than the view```css.card-wrapper {- container: inline-size / card; /* shorthand for container-type + container-name */+ container: card / inline-size; /* shorthand for container-name / container-type */}@container card (inline-size > 400px) {@@ -242,7 +248,7 @@ Manage layout shifts, scrollbars, and clipping predictably.- Use `overflow: auto` so scrollbars appear only when content actually overflows.- Use `overflow: clip` to clip content **without** establishing a scroll container; opt into spillover with `overflow-clip-margin`.- Use `scrollbar-gutter: stable` to reserve space for scrollbars and prevent layout shifts when content grows.-- Use `overscroll-behavior: contain` (or `none`) on scrollable containers to stop scroll chains from bubbling into the parent or document.+- Use `overscroll-behavior: contain` (or `none`) on nested scroll regions (such as sidebars, modals, and lists) to stop scroll chains from bubbling into the page, or `overscroll-behavior: chain` on intermediate scroll wrappers (such as swipe-to-reveal tracks) when excess scroll should propagate to an ancestor scroller without triggering a local rubber-band bounce.- Use the `-webkit-line-clamp` + `display: -webkit-box` + `-webkit-box-orient: vertical` triad for multi-line truncation — despite the prefix, this pattern is fully specified and not deprecated. Declare the unprefixed `line-clamp` shorthand alongside it; browsers that don't yet support it ignore the property harmlessly.**Do not:**@@ -266,7 +272,7 @@ Manage layout shifts, scrollbars, and clipping predictably.}```-> For `overflow: clip` and `overflow-clip-margin` in depth, see `overflow-clipping-control` (via `npx -y modern-web-guidance@latest retrieve "overflow-clipping-control"`). For scrollbar color, sizing, and theming, see `customize-scrollbar-color-and-thickness` (via `npx -y modern-web-guidance@latest retrieve "customize-scrollbar-color-and-thickness"`), `dark-mode` (via `npx -y modern-web-guidance@latest retrieve "dark-mode"`), and `adapt-scrollbar-to-contrast-preferences` (via `npx -y modern-web-guidance@latest retrieve "adapt-scrollbar-to-contrast-preferences"`).+> For `overflow: clip` and `overflow-clip-margin` in depth, see `overflow-clipping-control` (via `npx -y modern-web-guidance@latest retrieve "overflow-clipping-control"`). For nested scroll handoff with `overscroll-behavior: chain` in swipe-to-reveal UI, see `swipe-to-reveal` (via `npx -y modern-web-guidance@latest retrieve "swipe-to-reveal"`). For scrollbar color, sizing, and theming, see `customize-scrollbar-color-and-thickness` (via `npx -y modern-web-guidance@latest retrieve "customize-scrollbar-color-and-thickness"`), `dark-mode` (via `npx -y modern-web-guidance@latest retrieve "dark-mode"`), and `adapt-scrollbar-to-contrast-preferences` (via `npx -y modern-web-guidance@latest retrieve "adapt-scrollbar-to-contrast-preferences"`).## 7 Viewport mechanics and track distribution@@ -284,8 +290,7 @@ Browser support for Grid lanes: Limited availability.Supported by: Safari 26.4 (Mar 2026).Unsupported in: Chrome, Edge, and Firefox.--The spec is in development. The currently agreed-upon name is "grid lanes" (e.g., `display: grid-lanes`). Firefox ships `grid-template-rows: masonry` behind a flag; no other engines ship it in stable as of this writing.+The specification is in development under the name "grid lanes" (e.g., `display: grid-lanes`), while earlier experimental prototypes used `grid-template-rows: masonry`.**Do:**@@ -311,3 +316,4 @@ The spec is in development. The currently agreed-upon name is "grid lanes" (e.g.}}```+diff --git a/skills/modern-web-guidance/guides/css/dynamic-sibling-styling.md b/skills/modern-web-guidance/guides/css/dynamic-sibling-styling.mdindex b3a2dff..637f2d5 100644--- a/skills/modern-web-guidance/guides/css/dynamic-sibling-styling.md+++ b/skills/modern-web-guidance/guides/css/dynamic-sibling-styling.md@@ -59,7 +59,7 @@ By combining these functions with CSS trigonometry (`sin()`, `cos()`), you can p### Fallback strategiesBaseline status for sibling-count() and sibling-index(): Newly available. It's been Baseline since 2026-08-18.-Supported by: Chrome 138 (Jun 2025), Edge 138 (Jun 2025), Firefox 154, and Safari 26.2 (Dec 2025).+Supported by: Chrome 138 (Jun 2025), Edge 138 (Jun 2025), Firefox 154 (Aug 2026), and Safari 26.2 (Dec 2025).If `sibling-index()` and `sibling-count()` are not supported, provide a fallback by injecting CSS custom properties via JavaScript. **MANDATORY:** Use feature detection with `CSS.supports()` to ensure the script only runs when necessary.diff --git a/skills/modern-web-guidance/guides/forms/autofill-payment-form.md b/skills/modern-web-guidance/guides/forms/autofill-payment-form.mdindex 4848b21..1e3b39d 100644--- a/skills/modern-web-guidance/guides/forms/autofill-payment-form.md+++ b/skills/modern-web-guidance/guides/forms/autofill-payment-form.md@@ -37,9 +37,9 @@ Every `<input>`, `<select>`, and `<textarea>` element SHOULD have an appropriate### Make buttons helpful-Use `<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.+Use `<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 behavior, built-in form submission functionality, and can easily be styled.-Give each form submit button a value that says what it does. For each step towards checkout, use a descriptive call-to-action that shows progress and makes the next step obvious. For example, label the submit button on your delivery address form **Proceed to Payment** rather than **Continue** or **Save**.+Give each form submit button a value that says what it does. For each step toward checkout, use a descriptive call-to-action that shows progress and makes the next step obvious. For example, label the submit button on your delivery address form **Proceed to Payment** rather than **Continue** or **Save**.### Use a single name input where possible@@ -59,15 +59,16 @@ By default, set the billing address to be the same as the delivery address. ReduUse appropriate autocomplete values for the billing address, just as you do for shipping address, so the user doesn't have to enter data more than once. Add a prefix word to autocomplete attributes if you have different values for inputs with the same name in different sections. For example:-```-<input autocomplete="shipping address-line-1" ...>+```html+<!-- Prefix with shipping or billing; note that the valid token is address-line1 (no hyphen before the digit) -->+<input autocomplete="shipping address-line1" ...>...-<input autocomplete="billing address-line-1" ...>+<input autocomplete="billing address-line1" ...>```### Show checkout progress-For each step towards payment, use page headings and descriptive button values that make it clear what needs to be done now, and what checkout step is next.+For each step toward payment, use page headings and descriptive button values that make it clear what needs to be done now, and what checkout step is next.Use the `enterkeyhint` attribute on form inputs to set the mobile keyboard enter key label. For example, use `enterkeyhint="previous"` and `enterkeyhint="next"` within a multi-page form, `enterkeyhint="done"` for the final input in the form, and `enterkeyhint="search"` for a search input.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 e10a5ec..636555b 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@@ -136,6 +136,6 @@ Baseline status for inputmode: Widely available. It's been Baseline since 2021-1Supported 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).+Supported by: Chrome 153, Edge 153 (Sep 2026), 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 e25c9a9..0dcf5ee 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@@ -146,6 +146,6 @@ Baseline status for inputmode: Widely available. It's been Baseline since 2021-1Supported 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).+Supported by: Chrome 153, Edge 153 (Sep 2026), 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/ime-safe-enter-submit.md b/skills/modern-web-guidance/guides/forms/ime-safe-enter-submit.mdindex 07f23d8..200c839 100644--- a/skills/modern-web-guidance/guides/forms/ime-safe-enter-submit.md+++ b/skills/modern-web-guidance/guides/forms/ime-safe-enter-submit.md@@ -48,8 +48,9 @@ Note: Other custom submission shortcuts (such as `Cmd+Enter` or `Ctrl+Enter`) do## Fallback strategies-Baseline status for the api.KeyboardEvent.isComposing capability: Newly available. It's been Baseline since 2026-09-14.-Supported by: Chrome 56 (Jan 2017), Edge 79 (Jan 2020), Firefox 31 (Jul 2014), and Safari 27.+Browser support for the api.KeyboardEvent.isComposing capability: Limited availability.+Supported by: Chrome 56 (Jan 2017), Edge 79 (Jan 2020), and Firefox 31 (Jul 2014).+Unsupported in: Safari.In recent versions of Safari, an event-ordering issue (WebKit bug 165004) delivered `compositionend` to script handlers before the confirming `Enter` `keydown`, even though the underlying events were dispatched in the opposite order. By the time the keydown handler ran, `event.isComposing` had already been reset to `false`, meaning the standard check alone would have failed to prevent premature submission.diff --git a/skills/modern-web-guidance/guides/forms/slider.md b/skills/modern-web-guidance/guides/forms/slider.mdnew file mode 100644index 0000000..1e3cba1--- /dev/null+++ b/skills/modern-web-guidance/guides/forms/slider.md@@ -0,0 +1,182 @@+# Brand-Consistent Range Slider++## Use the native range input++Use a labeled `<input type="range">` rather than recreating a slider with `<div>` elements or custom pointer handlers. The native control preserves keyboard and pointer interaction, touch behavior, and accessibility support. Configure `min`, `max`, `step`, and `value` for the use case.++```html+<label for="range-slider">Volume</label>+<input type="range" id="range-slider" value="70"/>+```++If the value requires a formatted label or unit, expose it in ordinary DOM content and update `aria-valuetext` when changed. Do not use `::before` or `::after` on slider pseudo-elements, as generated content on form controls is not interoperable. If a tooltip that follows the thumb is required, use the `slider-tooltip` (via `npx -y modern-web-guidance@latest retrieve "slider-tooltip"`) guide.++## Choose the styling approach++For simple color customization, use `brand-consistent-forms` (via `npx -y modern-web-guidance@latest retrieve "brand-consistent-forms"`) and retain the browser’s native rendering:++```css+input[type="range"] {+ accent-color: var(--brand-color);+}+```++`accent-color` is not a complete slider styling API. Its effect on the thumb, track, and fill is user-agent-dependent. Use the pseudo-elements below when the track, thumb, dimensions, shape, or fill must be controlled.++## Style the track and thumb++Reset default OS styling with `appearance: none`, `margin: 0`, and `border: 0`. To normalize cross-browser rendering, declare WebKit and Firefox pseudo-elements in separate rule blocks, and center the WebKit thumb using `margin-block-start: calc((var(--slider-track-size) - var(--slider-thumb-size)) / 2)` (Firefox centers the thumb automatically). Keep consumer-facing values as custom properties on the input so themes do not target pseudo-elements directly.++```css+input[type="range"] {+ --slider-track-size: 0.5rem;+ --slider-thumb-size: 1.25rem;+ --slider-track-radius: 999px;+ --slider-thumb-radius: 50%;+ --slider-track-color: #d9d9d9;+ --slider-fill-color: #06c;+ --slider-thumb-color: var(--slider-fill-color);+ --slider-direction: to right;++ /* reverse gradient direction for right-to-left layouts */+ &:dir(rtl) {+ --slider-direction: to left;+ }++ /* Read min and max from attributes; --control-value is synced by the script below. */+ --attr-min: attr(min type(<number>), 0);+ --attr-max: attr(max type(<number>), 100);+ --control-value: attr(value type(<number>), 50);+ --slider-progress: calc(+ progress(var(--control-value), var(--attr-min), var(--attr-max)) * 100%+ );++ appearance: none;+ inline-size: 100%;+ block-size: 2.5rem; /* Preserve a generous interaction area. */+ margin: 0;+ padding: 0;+ border: 0;+ border-radius: 0;+ background: transparent;+ cursor: pointer;+}++/* WebKit/Blink. */+input[type="range"]::-webkit-slider-runnable-track {+ block-size: var(--slider-track-size);+ border: 0;+ border-radius: var(--slider-track-radius);+ background: linear-gradient(+ var(--slider-direction),+ var(--slider-fill-color) var(--slider-progress),+ var(--slider-track-color) var(--slider-progress)+ );+}++input[type="range"]::-webkit-slider-thumb {+ -webkit-appearance: none;+ appearance: none;+ inline-size: var(--slider-thumb-size);+ block-size: var(--slider-thumb-size);+ margin-block-start: calc(+ (var(--slider-track-size) - var(--slider-thumb-size)) / 2+ );+ border: 0;+ border-radius: var(--slider-thumb-radius);+ background: var(--slider-thumb-color);+}++/* Firefox. */+input[type="range"]::-moz-range-track {+ block-size: var(--slider-track-size);+ border: 0;+ border-radius: var(--slider-track-radius);+ background: var(--slider-track-color);+}++input[type="range"]::-moz-range-progress {+ block-size: var(--slider-track-size);+ border-radius: var(--slider-track-radius);+ background: var(--slider-fill-color);+}++input[type="range"]::-moz-range-thumb {+ inline-size: var(--slider-thumb-size);+ block-size: var(--slider-thumb-size);+ border: 0;+ border-radius: var(--slider-thumb-radius);+ background: var(--slider-thumb-color);+}+```++Always provide a visible keyboard focus indicator after removing the native appearance. Do not use color alone:++```css+input[type="range"]:focus-visible {+ outline: 2px solid var(--slider-fill-color);+ outline-offset: 4px;+}+```++## Style the active track++When the filled portion of the track is styled differently from the unfilled track, Firefox exposes it via `::-moz-range-progress`. WebKit/Blink do not provide an equivalent pseudo-element, so sync the live input value to `--control-value` on `input` events:++```js+const slider = document.querySelector('#range-slider');++function syncSliderValue() {+ slider.style.setProperty('--control-value', slider.value);+}++syncSliderValue();+slider.addEventListener('input', syncSliderValue);+```++## Limitations++- Do not combine WebKit and Firefox pseudo-selectors into a single comma-separated list (e.g. `::-webkit-slider-thumb, ::-moz-range-thumb`); browsers drop the entire rule if an unrecognized vendor pseudo-element is encountered.++## Fallbacks++### Fallbacks & browser support for accent-color++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.+Browsers that do not support this property will ignore it and use their default UI colors.++### Fallbacks & browser support for `progress()` and `attr()`++Baseline status for progress(): Newly available. It's been Baseline since 2026-09-01.+Supported by: Chrome 138 (Jun 2025), Edge 138 (Jun 2025), Firefox 155 (Sep 2026), and Safari 26 (Sep 2025).++When `progress()` is unsupported, compute `--slider-progress` with `calc()`:++```css+@supports not (opacity: progress(1, 0, 100)) {+ input[type="range"] {+ --slider-progress: calc(+ (var(--control-value) - var(--attr-min)) /+ (var(--attr-max) - var(--attr-min)) * 100%+ );+ }+}+```++Browser support for attr(): Limited availability.+Supported by: Chrome 133 (Feb 2025), Edge 133 (Feb 2025), and Firefox 155 (Sep 2026).+Unsupported in: Safari.++When typed `attr()` is unsupported, sync `--attr-min` and `--attr-max` from the input's `min` and `max` attributes in JavaScript:++```js+function syncSliderValue() {+ slider.style.setProperty('--attr-min', slider.min || 0);+ slider.style.setProperty('--attr-max', slider.max || 100);+ slider.style.setProperty('--control-value', slider.value);+}+```+diff --git a/skills/modern-web-guidance/guides/forms/switch.md b/skills/modern-web-guidance/guides/forms/switch.mdnew file mode 100644index 0000000..5e5151f--- /dev/null+++ b/skills/modern-web-guidance/guides/forms/switch.md@@ -0,0 +1,60 @@+# Build Accessible Switch Controls++Use the HTML `switch` attribute on `<input type="checkbox" switch>` with an associated `<label>` to build a binary on/off toggle that preserves native form submission, keyboard navigation, and screen reader semantics (see `checkbox` (via `npx -y modern-web-guidance@latest retrieve "checkbox"`) and `forms` (via `npx -y modern-web-guidance@latest retrieve "forms"`)).++## Markup++Add the boolean `switch` attribute to a standard checkbox input:++```html+<label>+ Enable notifications+ <input id="notifications" type="checkbox" switch>+</label>+```++- The label can wrap the input or be associated with `for`/`id`. All styling targets the input, so it doesn't depend on the label structure.+- When checked, the input submits its standard checkbox value. In JavaScript, listen for `change` (or `input`) events and read `.checked` rather than `.value`.++## Styling++Customize the control's highlight color using `accent-color` (see `brand-consistent-forms` (via `npx -y modern-web-guidance@latest retrieve "brand-consistent-forms"`)) and ensure visible focus styling:++```css+input[type="checkbox"][switch] {+ accent-color: var(--accent-color, #1769e0);+ margin: 0;+ cursor: pointer;+}++input[type="checkbox"][switch]:focus-visible {+ outline: 3px solid var(--focus-color, #ff8c00);+ outline-offset: 4px;+}+```++## Fallback strategies++### Fallbacks & browser support for switch-control++Browser support for <input type="checkbox" switch>: Limited availability.+Supported by: Safari 17.4 (Mar 2024).+Unsupported in: Chrome, Edge, and Firefox.++If your Baseline target does not support `<input type="checkbox" switch>`, load `input-switch-polyfill` only when `'switch' in HTMLInputElement.prototype` is `false`. Do not load the polyfill unconditionally. The polyfill enhances checkboxes with the `switch` attribute by setting `role="switch"`, applying switch styling (`appearance: none`), syncing computed `accent-color`, and providing pointer drag support.++Use the package-loading approach appropriate to your project. The example below assumes your setup can resolve module specifiers:++```javascript+if (!('switch' in HTMLInputElement.prototype)) {+ import('input-switch-polyfill');+}+```++### Fallbacks & browser support for accent-color++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.+Browsers that do not support this property will ignore it and use their default UI colors.diff --git a/skills/modern-web-guidance/guides/html/accessible-web-components.md b/skills/modern-web-guidance/guides/html/accessible-web-components.mdindex 02f9fde..2eae494 100644--- a/skills/modern-web-guidance/guides/html/accessible-web-components.md+++ b/skills/modern-web-guidance/guides/html/accessible-web-components.md@@ -16,6 +16,14 @@ class ToggleSwitch extends HTMLElement {this.#internals = this.attachInternals();this.#internals.role = 'switch'; // default role, no host attribute neededthis.#internals.ariaChecked = 'false'; // exposed to the accessibility tree+ this.addEventListener('click', () => this.toggle());+ this.addEventListener('keydown', (e) => {+ if (e.key === ' ') { e.preventDefault(); this.toggle(); }+ });+ }+ connectedCallback() {+ // Put the host in the tab order on connect (setting tabIndex in the constructor throws on createElement).+ if (!this.hasAttribute('tabindex')) this.tabIndex = 0;}toggle() {const on = this.#internals.ariaChecked !== 'true';@@ -29,14 +37,15 @@ This avoids polluting the DOM with ARIA attributes and prevents consumers from a## Focus management and `delegatesFocus`-- 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.+- When the **host element itself is the interactive control** and carries the role and state via `ElementInternals` (like `ToggleSwitch` above), put the host in the tab order inside `connectedCallback` (`if (!this.hasAttribute('tabindex')) this.tabIndex = 0` — never in the constructor, which throws on `document.createElement`) so focus lands on the host and assistive technology announces its role and state. Do not set `tabindex` on the host for static, non-interactive components (such as a callout or card).+- Attach the shadow root with `delegatesFocus: true` when the component **wraps an internal focusable control** that owns the semantics (or on a form-associated custom element with `static formAssociated = true`). Focusing the host (and clicking an associated `<label>` for form-associated elements) then forwards focus to the first focusable child, and `:focus` matches the host. Do not combine `delegatesFocus: true` with a role/state on the host, or focus will land on the inner element and skip the host's state.- 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 across shadow roots- **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.+- They do **not** resolve **inward**: an element can't reference *into* a descendant shadow tree (e.g. a host can't be labeled 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 strategiesdiff --git a/skills/modern-web-guidance/guides/html/custom-elements.md b/skills/modern-web-guidance/guides/html/custom-elements.mdindex 944073d..6d1a4b9 100644--- a/skills/modern-web-guidance/guides/html/custom-elements.md+++ b/skills/modern-web-guidance/guides/html/custom-elements.md@@ -9,7 +9,7 @@ The callbacks themselves are well documented; these are the misconceptions that- **`connectedCallback` can run more than once.** It fires on every insertion, so moving the element re-runs it. Make setup idempotent — don't assume a single first run.- **`connectedMoveCallback` skips the disconnect/reconnect pair on a move.** When an element is relocated with `Node.moveBefore()`, this callback fires *instead of* `disconnectedCallback` → `connectedCallback`, so state, focus, and iframe/media playback survive the move. Define it when your setup or teardown is expensive or observably re-runs.- **Tear down in `disconnectedCallback`.** Remove global listeners, timers, and observers or you leak; but the element may be re-inserted, so don't treat teardown as permanent.-- **Do not depend on the full DOM being present in the constructor.** Attributes are usually (but not always) present; long lists of children may not have finished parsing. Use `connectedCallback` for one-shot initialization, `slotchange` to monitor direct children, and `attributeChangedCallback` to monitor attributes. `connectedCallback` may still fire before all children are parsed, so do not ignore subsequent `slotchange` / `attributeChangedCallback` calls.+- **Call `super()` first in the constructor, and do not depend on the full DOM being present.** Calling `super()` after touching `this` throws a `ReferenceError`. Attributes are usually (but not always) present; long lists of children may not have finished parsing. Use `connectedCallback` for one-shot initialization, `slotchange` to monitor direct children, and `attributeChangedCallback` to monitor attributes. `connectedCallback` may still fire before all children are parsed, so do not ignore subsequent `slotchange` / `attributeChangedCallback` calls.- **`attributeChangedCallback` fires only for `observedAttributes`,** and should stay cheap for attributes that don't affect output.- **Lifecycle hooks and `observedAttributes` are snapshotted at registration.** `customElements.define()` reads both once; adding a hook or extending `observedAttributes` on the class *after* the call is silently ignored. In particular, `attributeChangedCallback` never fires unless `observedAttributes` was already present at `define()` time.@@ -41,7 +41,7 @@ Keep the HTML attribute and the JS property in sync so the element is usable fro```javascriptclass MyToggle extends HTMLElement {- static observedAttributes = ['label', 'disabled'];+ static observedAttributes = ['label', 'count', 'disabled'];// String attribute reflected via getter/setter.get label() { return this.getAttribute('label') ?? ''; }@@ -49,6 +49,10 @@ class MyToggle extends HTMLElement {v ? this.setAttribute('label', v) : this.removeAttribute('label');}+ // Numeric attribute: coerce from string on read, serialize on write.+ get count() { return Number(this.getAttribute('count')) || 0; }+ set count(v) { this.setAttribute('count', String(v)); }+// Boolean attribute: present = true, absent = false. Never set it to "false".get disabled() { return this.hasAttribute('disabled'); }set disabled(on) { this.toggleAttribute('disabled', !!on); }@@ -115,4 +119,4 @@ For styling these states — both inside the component and from a consumer's sty- Symbol-keyed properties are a middle ground: hidden from ordinary enumeration, but reachable by any code holding the symbol (export it, or expose it as a `static` field on the class). Because each symbol is unique, two symbols sharing a description never collide — handy when a subclass or sibling needs controlled access that `#` fields can't provide.- Do **not** shadow global attributes (`style`, `class`, `id`, `slot`, `part`, `title`, `lang`, `dir`) with your own properties; doing so breaks their built-in behavior. Note `disabled` is only global on form controls; on other elements you must implement its effect yourself.-When naming a new API surface, follow the platform's own conventions — see the [W3C naming principles](https://www.w3.org/TR/design-principles/#naming-is-hard).+When naming a new API surface, follow the platform's own conventions: use lowercase kebab-case with at least one hyphen for custom element tag names (for example `my-toggle`), `lowerCamelCase` for properties and methods, and lowercase attribute names synchronized with their corresponding properties.diff --git a/skills/modern-web-guidance/guides/html/form-associated-custom-elements.md b/skills/modern-web-guidance/guides/html/form-associated-custom-elements.mdindex 48f1006..ae0ab6c 100644--- a/skills/modern-web-guidance/guides/html/form-associated-custom-elements.md+++ b/skills/modern-web-guidance/guides/html/form-associated-custom-elements.md@@ -13,7 +13,12 @@ class RatingInput extends HTMLElement {constructor() {super();this.#internals = this.attachInternals();- this.attachShadow({ mode: 'open' });+ this.attachShadow({ mode: 'open', delegatesFocus: true });+ }++ connectedCallback() {+ // Validate initial state once attributes (such as `required`) are present.+ this.#validate();}get value() { return this.#value; }@@ -39,7 +44,14 @@ class RatingInput extends HTMLElement {// Optional FACE lifecycle hooks:formResetCallback() { this.value = ''; }- formDisabledCallback(disabled) { this.toggleAttribute('disabled', disabled); }+ formDisabledCallback(disabled) {+ // Disable internal controls so they leave the tab order and ignore clicks.+ // Do NOT toggle `disabled` on `this`, or a `<fieldset disabled>` toggle will+ // leave the host permanently stuck with its own `disabled` attribute.+ for (const el of this.shadowRoot.querySelectorAll('button')) {+ el.disabled = disabled;+ }+ }formStateRestoreCallback(state) { this.value = state; }}customElements.define('rating-input', RatingInput);@@ -50,7 +62,7 @@ Key points:- `static formAssociated = true` is **MANDATORY**; it unlocks the form-related `ElementInternals` methods and the `formXxxCallback` lifecycle.- `setFormValue(value)` is what submits, with no hidden input required. Pass a `FormData` for multi-value controls.- `setValidity(flags, message, anchor)` integrates with native constraint validation: the form won't submit while invalid, `:invalid`/`:valid` apply, and the anchor element receives focus on report. Call `setValidity({})` to clear. The interaction-aware `:user-valid`/`:user-invalid` pseudo-classes are *not* consistently wired up for form-associated elements across browsers — verify support before relying on them rather than assuming they track user interaction the way they do for native controls.-- Implement `formResetCallback`, `formDisabledCallback`, and `formStateRestoreCallback` so the element behaves like a native control on reset, `fieldset[disabled]`, and back/forward autofill restore.+- Implement `formResetCallback`, `formDisabledCallback`, and `formStateRestoreCallback` so the element behaves like a native control on reset, `fieldset[disabled]`, and back/forward autofill restore. In `formDisabledCallback(disabled)`, disable internal controls (or remove them from the tab order and ignore input) rather than setting `disabled` on the host — setting the host attribute inside the callback prevents re-enabling when an ancestor `<fieldset>` is re-enabled, and the host already matches `:disabled` automatically.- Follow platform conventions for dispatched events and prefer the built-in `input` and `change` events over custom ones. `input` fires when the value changes as a direct result of user action (typing, dragging a slider); `change` fires once per stream of changes, when the user commits (releasing the slider, blurring the field). Construct them with `InputEvent` and `Event` respectively.## Fallback strategiesdiff --git a/skills/modern-web-guidance/guides/html/prerendering-custom-elements.md b/skills/modern-web-guidance/guides/html/prerendering-custom-elements.mdindex 8a91316..dc5355d 100644--- a/skills/modern-web-guidance/guides/html/prerendering-custom-elements.md+++ b/skills/modern-web-guidance/guides/html/prerendering-custom-elements.md@@ -37,8 +37,11 @@ class MyCard extends HTMLElement {this.attachShadow({ mode: 'open' });this.shadowRoot.append(template.content.cloneNode(true));}- // Otherwise hydrate in place: wire up listeners against existing markup,- // and do NOT re-render; that would discard the server's DOM and flash.+ // Hydrate in place: attach listeners once against existing markup (not unguarded+ // in connectedCallback, which re-runs if the element moves in the DOM), and do+ // NOT re-render; that would discard the server's DOM and flash.+ this.shadowRoot.getElementById('toggle')+ ?.addEventListener('click', () => this.toggleAttribute('open'));}}```@@ -58,4 +61,4 @@ DSD renders correctly on first paint only if styles ship inside the declarativeBaseline status for Declarative shadow DOM: Widely available. It's been Baseline since 2024-02-20.Supported by: Chrome 111 (Mar 2023), Edge 111 (Mar 2023), Firefox 123 (Feb 2024), and Safari 16.4 (Mar 2023).-In engines that don't parse `shadowrootmode`, the template is inert and its content is not attached as a shadow root. Detect this (`HTMLTemplateElement.prototype.hasOwnProperty('shadowRootMode')`) and, if absent, attach the shadow root imperatively from the same markup during upgrade so the component still renders.+In engines that don't parse `shadowrootmode`, the template is inert and its content is not attached as a shadow root. Detect this (`Object.hasOwn(HTMLTemplateElement.prototype, 'shadowRootMode')`) and, if absent, attach the shadow root imperatively from the same markup during upgrade so the component still renders.diff --git a/skills/modern-web-guidance/guides/html/shadow-dom.md b/skills/modern-web-guidance/guides/html/shadow-dom.mdindex cfc9c07..5fd05d4 100644--- a/skills/modern-web-guidance/guides/html/shadow-dom.md+++ b/skills/modern-web-guidance/guides/html/shadow-dom.md@@ -8,7 +8,7 @@ A shadow root is an encapsulated DOM subtree attached to a host element: stylesthis.attachShadow({ mode: 'open', delegatesFocus: true });```-`delegatesFocus: true` makes focusing the host move focus to the first focusable element inside the shadow tree, and routes `:focus` styling to the host. Set it whenever the component wraps focusable controls; it is required for label-click and keyboard accessibility. (Use `mode: 'open'` in almost all cases — see the cross-cutting rules in `web-components` (via `npx -y modern-web-guidance@latest retrieve "web-components"`).)+`delegatesFocus: true` makes focusing the host move focus to the first focusable element inside the shadow tree, routes `:focus` styling to the host, and on form-associated custom elements (`static formAssociated = true`) forwards `<label>` clicks to the inner control. Set it whenever the component wraps focusable controls. Use `mode: 'open'` in almost all cases so dev tools, page scripts, and server hydration can reach `element.shadowRoot` (see `web-components` (via `npx -y modern-web-guidance@latest retrieve "web-components"`)).## Templates: construct the tree efficientlydiff --git a/skills/modern-web-guidance/guides/html/styling-web-components.md b/skills/modern-web-guidance/guides/html/styling-web-components.mdindex d90ac30..93fb7dc 100644--- a/skills/modern-web-guidance/guides/html/styling-web-components.md+++ b/skills/modern-web-guidance/guides/html/styling-web-components.md@@ -84,7 +84,7 @@ When a custom element wraps a native control (`<my-button>` around a real `<butt## `:state()`: style the component's own states-A custom element can expose internal boolean states through `ElementInternals` (see `custom-elements` (via `npx -y modern-web-guidance@latest retrieve "custom-elements"`) for setting them), and those states become a styling channel across the boundary — like `::part` and custom properties, but for *state* rather than structure or values. Match them inside the shadow tree with `:host(:state(name))`, and from a consumer's stylesheet with `tag-name:state(name)`:+A custom element can expose internal boolean states through `ElementInternals` via `this.#internals.states.add('busy')` and `.delete('busy')` (see `custom-elements` (via `npx -y modern-web-guidance@latest retrieve "custom-elements"`) for lifecycle usage), and those states become a styling channel across the boundary — like `::part` and custom properties, but for *state* rather than structure or values. Match them inside the shadow tree with `:host(:state(name))`, and from a consumer's stylesheet with `tag-name:state(name)`:```css/* Inside the component's shadow tree. */@@ -99,10 +99,13 @@ Unlike a reflected attribute, a custom state is **read-only to the outside**: co## `@layer` and container queries inside components- **Cascade layers** (`@layer`) work inside a shadow root and are scoped to it; a layer name in the shadow tree is independent of a same-named layer in the page. Use them to order your own component styles (e.g. `@layer base, theme;`) so consumer overrides via custom properties and `::part` still win predictably.-- **Container queries** are the right tool for responsive components: a component should respond to the space it's given, not the viewport. Declare the host or a wrapper as a container and query it, so the same component adapts in a sidebar or a full-width region.+- **Container queries** are the right tool for responsive components: a component should respond to the space it's given, not the viewport. Declare the host or a wrapper as a container (giving `:host` a layout box such as `display: block`, since custom elements default to `display: inline` and size containment does not apply to `inline` or `contents` elements) and query it, so the same component adapts in a sidebar or a full-width region.```css-:host { container-type: inline-size; }+:host {+ display: block; /* Required: size containment does not apply to default display: inline */+ container-type: inline-size;+}@container (min-width: 30rem) {.card { grid-template-columns: 1fr 2fr; }diff --git a/skills/modern-web-guidance/guides/performance/interaction-paint-timing.md b/skills/modern-web-guidance/guides/performance/interaction-paint-timing.mdindex 00c263c..b0bfc4a 100644--- a/skills/modern-web-guidance/guides/performance/interaction-paint-timing.md+++ b/skills/modern-web-guidance/guides/performance/interaction-paint-timing.md@@ -187,11 +187,11 @@ onINP(sendToAnalytics, { reportSoftNavs: true });## Fallback strategiesBrowser support for Interaction contentful paint performance entries: Limited availability.-Supported by: Chrome 151 and Edge 151.+Supported by: Chrome 151 (Jul 2026) and Edge 151 (Jul 2026).Unsupported in: Firefox and Safari.Browser support for Soft navigation performance entries: Limited availability.-Supported by: Chrome 151 and Edge 151.+Supported by: Chrome 151 (Jul 2026) and Edge 151 (Jul 2026).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):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.mdindex efe63b0..110ffb3 100644--- 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.md@@ -118,7 +118,7 @@ reducedMotionQuery.addEventListener('change', (event) => {## Fallback strategyBrowser support for Lazy-loading media: Limited availability.-Supported by: Chrome 150 and Edge 150.+Supported by: Chrome 150 (Jun 2026) and Edge 150 (Jul 2026).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: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 71975b5..4d9ecc5 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@@ -128,7 +128,7 @@ await response## Fallback strategiesBrowser support for <template for>: Limited availability.-Supported by: Chrome 150 and Edge 150.+Supported by: Chrome 150 (Jun 2026) and Edge 150 (Jul 2026).Unsupported in: Firefox and Safari.HTML setter methods is not natively supported by any major browser yet.@@ -136,7 +136,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.Browser support for HTML processing instructions: Limited availability.-Supported by: Chrome 150 and Edge 150.+Supported by: Chrome 150 (Jun 2026) and Edge 150 (Jul 2026).Unsupported in: Firefox and Safari.You can use polyfills like `template-for-polyfill` and `html-setters-polyfill` to emulate the API surface for non-supporting browsers.diff --git a/skills/modern-web-guidance/guides/security/client-side-encryption.md b/skills/modern-web-guidance/guides/security/client-side-encryption.mdnew file mode 100644index 0000000..3d359ae--- /dev/null+++ b/skills/modern-web-guidance/guides/security/client-side-encryption.md@@ -0,0 +1,302 @@+# Encrypt data client-side with WebCrypto++Use the Web Cryptography API (`crypto.subtle`) to establish shared secrets over untrusted networks using quantum-resistant Key Encapsulation Mechanisms (KEMs) or classical key agreement, and encrypt sensitive data in the browser with Authenticated Encryption with Associated Data (AEAD). For signing and verifying messages or artifacts without encrypting them, see `digital-signatures` (via `npx -y modern-web-guidance@latest retrieve "digital-signatures"`).++An end-to-end envelope encryption flow splits into two phases:++- **One-time recipient setup (Steps 1–2)**: The recipient generates a key pair, persists the `CryptoKeyPair` in IndexedDB for future sessions, and exports the public key (`'raw-public'`) to share with senders.+- **Per-message encryption (Steps 3–4)**: For each payload, the sender imports the recipient's public key, calls `encapsulateKey()` to generate a fresh one-time shared key and ciphertext capsule, encrypts the payload with a fresh 12-byte IV, and sends `{ capsule, iv, ciphertext }` to the recipient.++## 1. Choose a KEM algorithm and generate a recipient key pair++Unlike Diffie-Hellman key agreement (`deriveKey()`), where both parties combine their keys, a Key Encapsulation Mechanism (KEM) uses the recipient's public key to generate both a random shared secret and a ciphertext capsule in a single `encapsulateKey()` call. The recipient recovers the same shared key from the ciphertext capsule using `decapsulateKey()`.++Use **`'MLKEM768-X25519'`** by default: it combines post-quantum ML-KEM (standardized in NIST FIPS 203) with classical `'X25519'` so the shared secret remains secure as long as either algorithm holds. Choose standalone `'ML-KEM-768'` when a policy requires pure FIPS 203 output without a hybrid component, or `'ML-KEM-1024'` when a policy requires NIST Category 5 (CNSA 2.0) compliance.++| Algorithm name | Security level & use case | Public key (`'raw-public'`) | Private seed (`'raw-seed'`) | Ciphertext size |+|---|---|---|---|---|+| **`'MLKEM768-X25519'`** | **Hybrid post-quantum (`'ML-KEM-768'`) + classical (`'X25519'`); recommended default** | 1216 bytes | 32 bytes | 1120 bytes |+| `'ML-KEM-768'` | NIST Category 3 (~192-bit security); standalone post-quantum KEM | 1184 bytes | 64 bytes | 1088 bytes |+| `'ML-KEM-1024'` | NIST Category 5 (~256-bit security); highest security margin | 1568 bytes | 64 bytes | 1568 bytes |++- Pass `'MLKEM768-X25519'`, `'ML-KEM-768'`, or `'ML-KEM-1024'` as the algorithm name (aliases such as `'X-Wing'` or `'X25519MLKEM768'`, as well as `'ML-KEM-512'`, throw `NotSupportedError`).+- Pass `extractable: false` and `['encapsulateKey', 'decapsulateKey']` (or `['encapsulateBits', 'decapsulateBits']`) when generating a KEM key pair. Non-extractable `CryptoKey` and `CryptoKeyPair` objects can be persisted across sessions directly in IndexedDB via structured cloning (`objectStore.put(recipientKeyPair, 'recipient-kem-key')`) without ever exporting the private key bytes:++```javascript+const recipientKeyPair = await crypto.subtle.generateKey(+ 'MLKEM768-X25519',+ false,+ ['encapsulateKey', 'decapsulateKey'],+);+```++## 2. Export and import keys++Modern WebCrypto algorithms (`'MLKEM768-X25519'`, `'ML-KEM-768'`, `'ML-KEM-1024'`, and `'ChaCha20-Poly1305'`) **reject the legacy `'raw'` format** in `importKey()` and `exportKey()` with a `NotSupportedError`. Always specify the explicit key format:++- **`'raw-public'`**: Public key bytes (`1216`, `1184`, or `1568` bytes). Pass `['encapsulateKey']` (or `['encapsulateBits']`) when importing a KEM public key.+- **`'raw-seed'`**: Private key seed bytes (`32` bytes for `'MLKEM768-X25519'`; `64` bytes for `'ML-KEM-768'` and `'ML-KEM-1024'`). Pass `['decapsulateKey']` (or `['decapsulateBits']`) when importing a KEM private key (passing `['encapsulateKey', 'decapsulateKey']` to `importKey()` or `getPublicKey()` throws `SyntaxError`). Both `'raw'` and `'raw-private'` throw `NotSupportedError` on KEM private keys. Note that `'MLKEM768-X25519'` only supports `'raw-public'`, `'raw-seed'`, and `'jwk'`—it does **not** support `'spki'` or `'pkcs8'`.+- **`'raw-secret'`**: Symmetric secret key bytes (`'ChaCha20-Poly1305'`, and accepted on `'AES-GCM'` and `'HKDF'`).++Export the recipient's public key with `'raw-public'` so the public key bytes can be serialized (for example, as Base64 via `new Uint8Array(recipientPublicKeyBytes).toBase64()` or hex) and shared with senders:++```javascript+// Export the recipient's public key bytes+const recipientPublicKeyBytes = await crypto.subtle.exportKey(+ 'raw-public',+ recipientKeyPair.publicKey,+);++// Import the recipient's public key on the sender (usage must be ['encapsulateKey'])+const importedPublicKey = await crypto.subtle.importKey(+ 'raw-public',+ recipientPublicKeyBytes,+ 'MLKEM768-X25519',+ true,+ ['encapsulateKey'],+);+```++If you only hold a private `CryptoKey` (even with `extractable: false`) and need its corresponding public `CryptoKey`, call `crypto.subtle.getPublicKey()`:++```javascript+const publicKey = await crypto.subtle.getPublicKey(+ recipientKeyPair.privateKey,+ ['encapsulateKey'],+);+```++## 3. Encapsulate and decapsulate a shared key++`encapsulateKey()` and `decapsulateKey()` import the 32-byte (256-bit) KEM shared secret into a `CryptoKey` using the algorithm specified in `sharedKeyAlgorithm` (with `'raw-secret'` format). Pass `'ChaCha20-Poly1305'` or `'AES-GCM'` directly to produce an AEAD encryption key:++```javascript+// Sender encapsulates a 256-bit AEAD key and produces a ciphertext capsule+const { sharedKey: senderKey, ciphertext: encapsulatedCiphertext } =+ await crypto.subtle.encapsulateKey(+ 'MLKEM768-X25519',+ importedPublicKey,+ 'ChaCha20-Poly1305', // Or 'AES-GCM'+ false,+ ['encrypt', 'decrypt'],+ );++// Recipient decapsulates the ciphertext capsule to recover the identical AEAD key+const recipientKey = await crypto.subtle.decapsulateKey(+ 'MLKEM768-X25519',+ recipientKeyPair.privateKey,+ encapsulatedCiphertext,+ 'ChaCha20-Poly1305',+ false,+ ['encrypt', 'decrypt'],+);+```++### Domain separation with `'HKDF'`++To bind the shared key to a specific protocol context (`info` and `salt`) or derive multiple subkeys from a single encapsulation, pass `'HKDF'` as `sharedKeyAlgorithm` with `['deriveKey']` usage, then call `crypto.subtle.deriveKey()`:++```javascript+const { sharedKey: hkdfBaseKey, ciphertext } = await crypto.subtle.encapsulateKey(+ 'MLKEM768-X25519',+ importedPublicKey,+ 'HKDF',+ false,+ ['deriveKey'],+);++const aeadKey = await crypto.subtle.deriveKey(+ {+ name: 'HKDF',+ hash: 'SHA-256',+ salt: new Uint8Array(32),+ info: new TextEncoder().encode('envelope-v1'),+ },+ hkdfBaseKey,+ { name: 'AES-GCM', length: 256 },+ false,+ ['encrypt', 'decrypt'],+);+```++## 4. Encrypt and decrypt payloads (`'ChaCha20-Poly1305'` and `'AES-GCM'`)++Encrypt payload data with an AEAD algorithm (`'ChaCha20-Poly1305'` or `'AES-GCM'`) using a fresh, cryptographically random **12-byte (96-bit) initialization vector (`iv`)** for every encryption operation. Never reuse an `(iv, key)` pair. Choose `'ChaCha20-Poly1305'` for consistent constant-time performance across devices without dedicated AES hardware acceleration, or `'AES-GCM'` when interoperating with existing WebCrypto or FIPS 140 deployments.++- **`'ChaCha20-Poly1305'`**: Uses a fixed 256-bit (32-byte) key (`generateKey('ChaCha20-Poly1305', extractable, ['encrypt', 'decrypt'])` takes a string or `{ name: 'ChaCha20-Poly1305' }` with **no `length` property**). The `iv` must be exactly 12 bytes, and the 128-bit Poly1305 authentication tag is appended to the ciphertext.+- **`'AES-GCM'`**: Pass `{ name: 'AES-GCM', length: 256 }` when calling `generateKey()` or `deriveKey()`, and a 12-byte `iv` when calling `encrypt()` and `decrypt()`.+- **`additionalData` (AAD)**: Bind unencrypted metadata (such as a record ID, recipient ID, or protocol version) to the authentication tag via `additionalData` so tampering with either the ciphertext or the metadata causes `decrypt()` to reject with `OperationError`.++```javascript+/**+ * Encrypts UTF-8 text with an AEAD CryptoKey ('ChaCha20-Poly1305' or 'AES-GCM').+ * @param {CryptoKey} key+ * @param {string} plaintext+ * @param {Uint8Array} [additionalData]+ */+export async function encryptMessage(key, plaintext, additionalData = new Uint8Array(0)) {+ // Always generate a fresh 12-byte (96-bit) IV per message+ const iv = crypto.getRandomValues(new Uint8Array(12));+ const encoded = new TextEncoder().encode(plaintext);++ const ciphertextBuffer = await crypto.subtle.encrypt(+ {+ name: key.algorithm.name,+ iv,+ additionalData,+ },+ key,+ encoded,+ );++ return { iv, ciphertext: new Uint8Array(ciphertextBuffer) };+}++/**+ * Decrypts and authenticates an AEAD payload. Throws OperationError if tampered.+ * @param {CryptoKey} key+ * @param {Uint8Array} iv+ * @param {Uint8Array} ciphertext+ * @param {Uint8Array} [additionalData]+ */+export async function decryptMessage(key, iv, ciphertext, additionalData = new Uint8Array(0)) {+ const plaintextBuffer = await crypto.subtle.decrypt(+ {+ name: key.algorithm.name,+ iv,+ additionalData,+ },+ key,+ ciphertext,+ );++ return new TextDecoder().decode(plaintextBuffer);+}+```++## Fallback strategies++Baseline status for Web Cryptography: Widely available. It's been Baseline since 2017-09-19.+Supported by: Chrome 37 (Aug 2014), Edge 12 (Jul 2015), Firefox 34 (Dec 2014), and Safari 11 (Sep 2017).++Baseline status for the api.SubtleCrypto.deriveBits.x25519 capability: Newly available. It's been Baseline since 2025-02-06.+Supported by: Chrome 133 (Feb 2025), Edge 133 (Feb 2025), Firefox 130 (Sep 2024), and Safari 17 (Sep 2023).++If your Baseline target does not yet support `SubtleCrypto.supports()`, `encapsulateKey()`, or `'ChaCha20-Poly1305'`, detect support using the **static** `SubtleCrypto.supports()` method and fall back to ephemeral-static Diffie-Hellman key agreement (`'X25519'` + `'HKDF'` + `'AES-GCM'`, or `'ECDH'` with `'P-256'` when targeting browsers prior to `'X25519'` support):++- **Call `SubtleCrypto.supports()` on the `SubtleCrypto` constructor, not on `crypto.subtle`**: `globalThis.SubtleCrypto?.supports?.('encapsulateKey', 'MLKEM768-X25519', 'ChaCha20-Poly1305')` is a synchronous static method returning a boolean (`crypto.subtle.supports` is `undefined`). Note that `SubtleCrypto.supports()` validates operation-specific parameters: bare algorithm strings work for `'encapsulateKey'`, `'decapsulateKey'`, `'generateKey'`, `'importKey'`, `'exportKey'`, and `'getPublicKey'`, whereas probing `'encrypt'` or `'decrypt'` directly requires an `iv` (for example, `SubtleCrypto.supports('encrypt', { name: 'ChaCha20-Poly1305', iv: new Uint8Array(12) })`).+- **Key format in the fallback (`'raw'`)**: While browsers that support Modern WebCrypto also accept `'raw-public'` on `'X25519'` and `'ECDH'`, use `'raw'` in fallback paths targeting older browsers.+- **Classical fallback (`'X25519'` + `'HKDF'` + `'AES-GCM'`)**: When `SubtleCrypto.supports()` is unavailable or returns `false`, generate an ephemeral `'X25519'` key pair for the sender, export the ephemeral public key as the capsule bytes, derive 256 bits via `deriveBits({ name: 'X25519', public: peerPublicKey }, privateKey, 256)`, and pass those bits through `'HKDF'` (`'SHA-256'`) to derive a 256-bit `'AES-GCM'` key.++```javascript+const KEM_PUBLIC_KEY_ALGORITHMS = {+ 1184: 'ML-KEM-768',+ 1216: 'MLKEM768-X25519',+ 1568: 'ML-KEM-1024',+};++export function supportsPostQuantumEnvelope() {+ return (+ typeof globalThis.SubtleCrypto?.supports === 'function' &&+ SubtleCrypto.supports('encapsulateKey', 'MLKEM768-X25519', 'ChaCha20-Poly1305')+ );+}++export async function generateRecipientKeys() {+ if (supportsPostQuantumEnvelope()) {+ const keyPair = await crypto.subtle.generateKey(+ 'MLKEM768-X25519',+ false,+ ['encapsulateKey', 'decapsulateKey'],+ );+ const publicKeyBytes = new Uint8Array(+ await crypto.subtle.exportKey('raw-public', keyPair.publicKey),+ );+ return { suite: 'MLKEM768-X25519+ChaCha20-Poly1305', keyPair, publicKeyBytes };+ }++ // Classical fallback: X25519 key agreement + HKDF + AES-GCM+ const keyPair = await crypto.subtle.generateKey('X25519', false, ['deriveBits']);+ const publicKeyBytes = new Uint8Array(+ await crypto.subtle.exportKey('raw', keyPair.publicKey),+ );+ return { suite: 'X25519+HKDF+AES-GCM', keyPair, publicKeyBytes };+}++async function deriveFallbackAesKey(privateKey, peerPublicKey, infoBytes = new Uint8Array(0)) {+ const sharedSecret = await crypto.subtle.deriveBits(+ { name: 'X25519', public: peerPublicKey },+ privateKey,+ 256,+ );+ const hkdfKey = await crypto.subtle.importKey('raw', sharedSecret, 'HKDF', false, ['deriveKey']);+ return crypto.subtle.deriveKey(+ {+ name: 'HKDF',+ hash: 'SHA-256',+ salt: new Uint8Array(32),+ info: infoBytes,+ },+ hkdfKey,+ { name: 'AES-GCM', length: 256 },+ false,+ ['encrypt', 'decrypt'],+ );+}++export async function encapsulateEnvelopeKey(+ recipientPublicKeyOrBytes,+ infoBytes = new Uint8Array(0),+) {+ const pubKey =+ recipientPublicKeyOrBytes instanceof CryptoKey+ ? recipientPublicKeyOrBytes+ : await (() => {+ const bytes =+ recipientPublicKeyOrBytes instanceof Uint8Array+ ? recipientPublicKeyOrBytes+ : new Uint8Array(recipientPublicKeyOrBytes);+ const kemName = KEM_PUBLIC_KEY_ALGORITHMS[bytes.byteLength];+ return kemName+ ? crypto.subtle.importKey('raw-public', bytes, kemName, true, ['encapsulateKey'])+ : crypto.subtle.importKey('raw', bytes, 'X25519', true, []);+ })();++ if (pubKey.algorithm.name !== 'X25519') {+ const { sharedKey, ciphertext } = await crypto.subtle.encapsulateKey(+ pubKey.algorithm.name,+ pubKey,+ 'ChaCha20-Poly1305',+ false,+ ['encrypt', 'decrypt'],+ );+ return { sharedKey, capsuleBytes: new Uint8Array(ciphertext) };+ }++ // Classical fallback: generate ephemeral X25519 key pair and send ephemeral public key as capsule+ const ephemeral = await crypto.subtle.generateKey('X25519', false, ['deriveBits']);+ const capsuleBytes = new Uint8Array(await crypto.subtle.exportKey('raw', ephemeral.publicKey));+ const sharedKey = await deriveFallbackAesKey(ephemeral.privateKey, pubKey, infoBytes);+ return { sharedKey, capsuleBytes };+}++export async function decapsulateEnvelopeKey(+ recipientPrivateKey,+ capsuleBytes,+ infoBytes = new Uint8Array(0),+) {+ if (recipientPrivateKey.algorithm.name !== 'X25519') {+ return crypto.subtle.decapsulateKey(+ recipientPrivateKey.algorithm.name,+ recipientPrivateKey,+ capsuleBytes,+ 'ChaCha20-Poly1305',+ false,+ ['encrypt', 'decrypt'],+ );+ }++ const ephemeralPubKey = await crypto.subtle.importKey('raw', capsuleBytes, 'X25519', true, []);+ return deriveFallbackAesKey(recipientPrivateKey, ephemeralPubKey, infoBytes);+}+```diff --git a/skills/modern-web-guidance/guides/security/digital-signatures.md b/skills/modern-web-guidance/guides/security/digital-signatures.mdnew file mode 100644index 0000000..0aea909--- /dev/null+++ b/skills/modern-web-guidance/guides/security/digital-signatures.md@@ -0,0 +1,235 @@+# Sign and verify data with WebCrypto++Use the Web Cryptography API (`crypto.subtle`) to sign and verify messages, tokens, or artifacts in the browser using quantum-resistant (ML-DSA) or classical (`'Ed25519'`, `'ECDSA'`) asymmetric keys. Digital signatures guarantee data integrity and signer authenticity without requiring shared secret keys. For establishing shared secrets and encrypting confidential payloads, see `client-side-encryption` (via `npx -y modern-web-guidance@latest retrieve "client-side-encryption"`).++## 1. Choose an algorithm and generate a key pair++ML-DSA (Module-Lattice-Based Digital Signature Algorithm, standardized in NIST FIPS 204) provides post-quantum lattice-based digital signatures resistant to attacks by both classical and quantum computers.++Use **`'ML-DSA-65'`** by default for general-purpose signing. Choose `'ML-DSA-44'` when you need smaller public keys and signatures over bandwidth-constrained channels and 128-bit security is sufficient, or `'ML-DSA-87'` when a security policy requires NIST Category 5 (CNSA 2.0) compliance.++| Algorithm name | Security level & use case | Public key (`'raw-public'`) | Signature size |+|---|---|---|---|+| `'ML-DSA-44'` | NIST Category 2 (~128-bit security); smallest keys and signatures | 1312 bytes | 2420 bytes |+| **`'ML-DSA-65'`** | **NIST Category 3 (~192-bit security); recommended default** | 1952 bytes | 3309 bytes |+| `'ML-DSA-87'` | NIST Category 5 (~256-bit security); highest security margin | 2592 bytes | 4627 bytes |++- Pass `'ML-DSA-44'`, `'ML-DSA-65'`, or `'ML-DSA-87'` as the algorithm name (pre-standardization names such as `'Dilithium'` or `'CRYSTALS-Dilithium'` throw `NotSupportedError`).+- Neither ML-DSA nor `'Ed25519'` takes a `hash` parameter.+- Pass `['sign', 'verify']` when generating a key pair with `generateKey()`:++```javascript+const signerKeyPair = await crypto.subtle.generateKey(+ 'ML-DSA-65',+ false,+ ['sign', 'verify'],+);+```++## 2. Export and import keys++`'ML-DSA-44'`, `'ML-DSA-65'`, and `'ML-DSA-87'` **reject the legacy `'raw'` format** in `importKey()` and `exportKey()` with a `NotSupportedError`. Always export or import keys using an explicit format:++- **`'raw-public'`**: Public key bytes (`1312`, `1952`, or `2592` bytes). Pass `['verify']` as the key usage when importing a public key.+- **`'raw-seed'`**: 32-byte private key seed for all three ML-DSA algorithms. Both `'raw'` and `'raw-private'` throw `NotSupportedError` on ML-DSA—store or transmit private keys using `'raw-seed'`, `'pkcs8'` (54 bytes), or `'jwk'` (`kty: 'AKP'`). Pass `['sign']` as the key usage when importing a private key (passing `['sign', 'verify']` to `importKey()` throws `SyntaxError`).+- **`'spki'`, `'pkcs8'`, and `'jwk'`**: Supported for all three ML-DSA algorithms.++Always export the verification public key with `'raw-public'` so the public key bytes can be serialized or shared with verifiers:++```javascript+// Export the public key bytes on the signer+const publicKeyBytes = await crypto.subtle.exportKey(+ 'raw-public',+ signerKeyPair.publicKey,+);++// Import the public key bytes on the verifier (usage must be ['verify'] only)+const verifierPublicKey = await crypto.subtle.importKey(+ 'raw-public',+ publicKeyBytes,+ 'ML-DSA-65',+ true,+ ['verify'],+);+```++If you only hold a private signing `CryptoKey` (even with `extractable: false`) and need its corresponding public `CryptoKey`, call `crypto.subtle.getPublicKey()` with `['verify']`:++```javascript+const publicKey = await crypto.subtle.getPublicKey(+ signerKeyPair.privateKey,+ ['verify'],+);+```++## 3. Sign and verify payloads++Call `crypto.subtle.sign()` with the private key to produce a signature, and `crypto.subtle.verify()` with the public key to check it:++```javascript+const payloadBytes = new TextEncoder().encode(+ '{"artifact":"release-v2.4.0.tar.gz","sha256":"9f86d08..."}',+);++const signatureBuffer = await crypto.subtle.sign(+ 'ML-DSA-65',+ signerKeyPair.privateKey,+ payloadBytes,+);++const isValid = await crypto.subtle.verify(+ 'ML-DSA-65',+ verifierPublicKey,+ signatureBuffer,+ payloadBytes,+);+```++### Domain separation with `ContextParams`++To prevent a signature created for one purpose from being replayed in another part of your application or protocol that shares the same key pair, bind the signature to a domain-separation `context`.++Instead of a bare algorithm name string, pass a `ContextParams` dictionary (`{ name, context }`) to `sign()` and `verify()`, where `context` is a `BufferSource` (`Uint8Array` or `ArrayBuffer`):++```javascript+const contextBytes = new TextEncoder().encode('release-manifest-v1');++const signatureBuffer = await crypto.subtle.sign(+ {+ name: 'ML-DSA-65',+ context: contextBytes,+ },+ signerKeyPair.privateKey,+ payloadBytes,+);++const isValid = await crypto.subtle.verify(+ {+ name: 'ML-DSA-65',+ context: contextBytes,+ },+ verifierPublicKey,+ signatureBuffer,+ payloadBytes,+);+```++- **255-byte limit**: `context` accepts `0` to `255` bytes (omitting `context` is equivalent to passing an empty `new Uint8Array(0)`). Passing more than `255` bytes rejects with `OperationError`.+- **Exact match required**: `crypto.subtle.verify()` returns `true` only when the verifier passes the exact same `context` bytes used during `crypto.subtle.sign()`.++## Fallback strategies++Baseline status for Web Cryptography: Widely available. It's been Baseline since 2017-09-19.+Supported by: Chrome 37 (Aug 2014), Edge 12 (Jul 2015), Firefox 34 (Dec 2014), and Safari 11 (Sep 2017).++Baseline status for the api.SubtleCrypto.sign.ed25519 capability: Newly available. It's been Baseline since 2025-05-29.+Supported by: Chrome 137 (May 2025), Edge 137 (May 2025), Firefox 129 (Aug 2024), and Safari 17 (Sep 2023).++If your Baseline target does not yet support `SubtleCrypto.supports()` or ML-DSA, detect support using the **static** `SubtleCrypto.supports()` method and fall back to classical `'Ed25519'` (or `'ECDSA'` with `'P-256'` and `'SHA-256'` when targeting browsers prior to `'Ed25519'` support):++- **Call `SubtleCrypto.supports()` on the `SubtleCrypto` constructor, not on `crypto.subtle`**: `globalThis.SubtleCrypto?.supports?.('sign', 'ML-DSA-65')` is a synchronous static method returning a boolean (`crypto.subtle.supports` is `undefined`). Probe `'sign'`, `'verify'`, `'generateKey'`, `'importKey'`, `'exportKey'`, or `'getPublicKey'` (or pass a `ContextParams` dictionary such as `SubtleCrypto.supports('sign', { name: 'ML-DSA-65', context })`).+- **Key format in the fallback (`'raw'`)**: While browsers that support Modern WebCrypto also accept `'raw-public'` on `'Ed25519'` and `'ECDSA'`, use `'raw'` in fallback paths targeting older browsers.+- **Domain separation in the fallback**: Classical WebCrypto algorithms (`'Ed25519'` and `'ECDSA'`) do not read a `context` property from the algorithm dictionary (WebIDL silently ignores unknown dictionary properties on `Algorithm` and `EcdsaParams`). Prepend a length-prefixed `context` header to the payload in your fallback path so domain separation behaves consistently across both suites.++```javascript+const ML_DSA_PUBLIC_KEY_ALGORITHMS = {+ 1312: 'ML-DSA-44',+ 1952: 'ML-DSA-65',+ 2592: 'ML-DSA-87',+};++export function supportsPostQuantumSignatures() {+ return (+ typeof globalThis.SubtleCrypto?.supports === 'function' &&+ SubtleCrypto.supports('sign', 'ML-DSA-65')+ );+}++export async function generateSigningKeyPair() {+ if (supportsPostQuantumSignatures()) {+ const keyPair = await crypto.subtle.generateKey('ML-DSA-65', false, ['sign', 'verify']);+ const publicKeyBytes = new Uint8Array(+ await crypto.subtle.exportKey('raw-public', keyPair.publicKey),+ );+ return {+ suite: 'ML-DSA-65',+ keyFormat: 'raw-public',+ keyPair,+ publicKeyBytes,+ };+ }++ // Classical fallback: Ed25519+ const keyPair = await crypto.subtle.generateKey('Ed25519', false, ['sign', 'verify']);+ const publicKeyBytes = new Uint8Array(await crypto.subtle.exportKey('raw', keyPair.publicKey));+ return {+ suite: 'Ed25519',+ keyFormat: 'raw',+ keyPair,+ publicKeyBytes,+ };+}++function frameFallbackInput(payloadBytes, contextBytes) {+ if (contextBytes.byteLength > 255) {+ throw new DOMException('Context must not exceed 255 bytes', 'OperationError');+ }+ const framed = new Uint8Array(1 + contextBytes.byteLength + payloadBytes.byteLength);+ framed[0] = contextBytes.byteLength;+ framed.set(contextBytes, 1);+ framed.set(payloadBytes, 1 + contextBytes.byteLength);+ return framed;+}++export async function signPayload(+ privateKey,+ payloadBytes,+ contextBytes = new Uint8Array(0),+) {+ if (privateKey.algorithm.name.startsWith('ML-DSA')) {+ const sig = await crypto.subtle.sign(+ { name: privateKey.algorithm.name, context: contextBytes },+ privateKey,+ payloadBytes,+ );+ return new Uint8Array(sig);+ }++ const framed = frameFallbackInput(payloadBytes, contextBytes);+ const sig = await crypto.subtle.sign('Ed25519', privateKey, framed);+ return new Uint8Array(sig);+}++export async function verifyPayload(+ publicKeyOrBytes,+ signatureBytes,+ payloadBytes,+ contextBytes = new Uint8Array(0),+) {+ const publicKey =+ publicKeyOrBytes instanceof CryptoKey+ ? publicKeyOrBytes+ : await (() => {+ const bytes =+ publicKeyOrBytes instanceof Uint8Array+ ? publicKeyOrBytes+ : new Uint8Array(publicKeyOrBytes);+ const mlDsaName = ML_DSA_PUBLIC_KEY_ALGORITHMS[bytes.byteLength];+ return mlDsaName+ ? crypto.subtle.importKey('raw-public', bytes, mlDsaName, true, ['verify'])+ : crypto.subtle.importKey('raw', bytes, 'Ed25519', true, ['verify']);+ })();++ if (publicKey.algorithm.name.startsWith('ML-DSA')) {+ return crypto.subtle.verify(+ { name: publicKey.algorithm.name, context: contextBytes },+ publicKey,+ signatureBytes,+ payloadBytes,+ );+ }++ const framed = frameFallbackInput(payloadBytes, contextBytes);+ return crypto.subtle.verify('Ed25519', publicKey, signatureBytes, framed);+}+```diff --git a/skills/modern-web-guidance/guides/security/local-network-access.md b/skills/modern-web-guidance/guides/security/local-network-access.mdindex 03ae6da..262a837 100644--- a/skills/modern-web-guidance/guides/security/local-network-access.md+++ b/skills/modern-web-guidance/guides/security/local-network-access.md@@ -6,7 +6,7 @@ Local Network Access splits access into two granular permissions and `Permission- **`local-network`**: Required when connecting from a `public` origin to the `local` address space (RFC 1918 private IPv4 ranges `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, link-local `169.254.0.0/16` / `fe80::/10`, IPv6 Unique Local Addresses `fc00::/7`, and `.local` mDNS hostnames).- **`loopback-network`**: Required when connecting from a `public` or `local` origin to the `loopback` address space (`127.0.0.0/8`, `::1/128`, or `localhost`).-Because `localhost` (`127.0.0.1`) is already in the most private (`loopback`) address space, serving your web app from `http://localhost` during local development will **not** trigger LNA checks by default. To test LNA prompts and permission states locally without deploying to a public server, either override your local dev server's address space to `public` using the `--ip-address-space-overrides=127.0.0.1:8080=public` Chromium flag, or manually toggle **Local network** and **Loopback network** between `Ask`, `Allow`, and `Block` in browser **Site settings**.+Because `localhost` (`127.0.0.1` and `[::1]`) is already in the most private (`loopback`) address space, serving your web app from `http://localhost` during local development will **not** trigger LNA checks by default. To test LNA prompts and permission states locally without deploying to a public server, either override your local dev server's IPv4 and IPv6 address space to `public` using the `--ip-address-space-overrides=127.0.0.1:8080=public,[::1]:8080=public` Chromium flag, or manually toggle **Local network** and **Loopback network** between `Ask`, `Allow`, and `Block` in browser **Site settings**.**MANDATORY:** Serve any web application that initiates local or loopback network requests from a **Secure Context (`https://`)**. Local Network Access permissions are denied automatically in insecure (`http://`) top-level contexts.@@ -105,20 +105,18 @@ export async function fetchLoopbackDaemon(daemonUrl = 'http://127.0.0.1:45678/heLocal Network Access restrictions also govern `WebSocket` and `WebTransport` connections:-- **`WebSocket`**: Pass a `WebSocketInit` options dictionary as the second argument (`{ protocols, targetAddressSpace: 'local' | 'loopback' }`) when opening a `ws://` connection to a local or loopback endpoint from an `https://` page.+- **`WebSocket`**: The `WebSocket(url, protocols)` constructor only accepts a subprotocol string or array as its second argument—do **not** pass a `{ targetAddressSpace }` options object, which throws a `SyntaxError`. Instead, the browser inspects the `WebSocket` URL before DNS resolution: `ws://` connections initiated from an `https://` page are exempted from Mixed Content blocking when the URL host is syntactically recognizable as local or loopback—specifically a private or loopback IP literal (`ws://192.168.1.100:8080`, `ws://127.0.0.1:8080`, `ws://[::1]:8080`), `localhost` (`*.localhost`), or a `.local` mDNS hostname (`ws://device.local:8080`)—and gated behind the `local-network` or `loopback-network` permission prompt. If a local endpoint is addressed via a custom non-`.local` DNS hostname, connect over `wss://`.- **`WebTransport`**: Because `WebTransport` strictly requires `https://` (HTTP/3 over QUIC with TLS or `serverCertificateHashes` for local self-signed certificates), it never triggers Mixed Content blocks and does not accept a `targetAddressSpace` option. Instead, the browser automatically verifies the resolved IP address space and gates the `transport.ready` promise behind the `local-network` or `loopback-network` permission prompt.```javascript/**- * Opens a WebSocket connection to a local network device with targetAddressSpace.+ * Opens a WebSocket connection to a local network device (IP literal, .local, or localhost).*/export function openLocalWebSocket(wsUrl = 'ws://192.168.1.100:8080/stream') {- // Pass WebSocketInit with targetAddressSpace so ws:// from an https:// page- // is permitted once the user grants 'local-network' permission.- const socket = new WebSocket(wsUrl, {- protocols: ['v1.telemetry'],- targetAddressSpace: 'local',- });+ // Pass only subprotocol string(s) as the second argument (never an options object).+ // Browsers exempt ws:// from Mixed Content when the host is a local/loopback IP literal,+ // .local, or localhost, and gate the connection on 'local-network' or 'loopback-network'.+ const socket = new WebSocket(wsUrl, ['v1.telemetry']);return socket;}@@ -167,12 +165,11 @@ Browser support for Local network access: Limited availability.Supported by: Chrome 142 (Oct 2025) and Edge 142 (Oct 2025).Unsupported in: Firefox and Safari.-Because Local Network Access permissions and `targetAddressSpace` options are not yet supported across all browsers (and older browser versions only accepted a protocol string/array in `new WebSocket(url, protocols)`), implement **feature detection with progressive fallback**:+If your Baseline target does not support Local Network Access permissions and `targetAddressSpace` options, implement **feature detection with progressive fallback**:1. **Permission Query Fallback**: Wrap `navigator.permissions.query({ name: permissionName })` in a `try / catch`. If the browser throws a `TypeError` because `'local-network'` or `'loopback-network'` is an unrecognized `PermissionName`, treat the state as `'prompt'` so the request still runs on an explicit user click (the connection attempt itself triggers the browser prompt where LNA is supported).2. **DO NOT** query the legacy combined permission name `{ name: 'local-network-access' }`. In older Chrome versions this query crashes the renderer process, and `try / catch` cannot prevent it. Newer Chrome versions treat `'local-network-access'` only as a legacy alias for the granular permissions.-3. **`WebSocket` Constructor Fallback**: Wrap `new WebSocket(url, { protocols, targetAddressSpace })` in a `try / catch` and fall back to `new WebSocket(url, protocols)` when the browser does not support the `WebSocketInit` options dictionary.-4. **Graceful Rejection Handling**: Always wrap `fetch()`, `WebSocket` error events, and `transport.ready` in error handlers that catch `TypeError` / connection failures and present clear remediation steps (checking that the local device is powered on, connected to the same network, and allowed in browser permissions).+3. **Graceful Rejection Handling**: Always wrap `fetch()`, `WebSocket` error events, and `transport.ready` in error handlers that catch `TypeError` / connection failures and present clear remediation steps (checking that the local device is powered on, connected to the same network, and allowed in browser permissions).```javascript/**@@ -192,16 +189,4 @@ export async function queryLnaPermissionSafe(permissionName) {return 'prompt';}}--/**- * Cross-browser WebSocket helper that uses WebSocketInit ({ protocols, targetAddressSpace })- * when supported and falls back to standard new WebSocket(url, protocols).- */-export function connectLocalWebSocketSafe(url, { protocols = [], targetAddressSpace = 'local' } = {}) {- try {- return new WebSocket(url, { protocols, targetAddressSpace });- } catch {- return new WebSocket(url, protocols);- }-}```diff --git a/skills/modern-web-guidance/guides/security/restrict-outbound-connections.md b/skills/modern-web-guidance/guides/security/restrict-outbound-connections.mdindex 590dd45..b33393e 100644--- a/skills/modern-web-guidance/guides/security/restrict-outbound-connections.md+++ b/skills/modern-web-guidance/guides/security/restrict-outbound-connections.md@@ -146,7 +146,7 @@ export async function fetchWithPolicyHandling(url, { statusElement, ...fetchOpti## Fallback strategyBrowser support for Connection allowlists: Limited availability.-Supported by: Chrome 152 and Edge 152.+Supported by: Chrome 152 (Aug 2026) and Edge 152 (Aug 2026).Unsupported in: Firefox and Safari.Because `Connection-Allowlist` is enforced at the browser network layer via an HTTP response header, it cannot be polyfilled in client-side JavaScript. If your Baseline target includes browsers that do not yet support `Connection-Allowlist`, **pair `Connection-Allowlist` with a `Content-Security-Policy` (CSP) header** (and a `<meta http-equiv="Content-Security-Policy">` element for document-level fetch and subresource restrictions when HTTP response headers cannot be configured):diff --git a/skills/modern-web-guidance/guides/security/sanitize-untrusted-html.md b/skills/modern-web-guidance/guides/security/sanitize-untrusted-html.mdindex cb6bfe7..a1a051b 100644--- a/skills/modern-web-guidance/guides/security/sanitize-untrusted-html.md+++ b/skills/modern-web-guidance/guides/security/sanitize-untrusted-html.md@@ -91,13 +91,15 @@ export async function safeSetHTML(el, html) {el.innerHTML = DOMPurify.sanitize(html, {ALLOWED_TAGS: [...elements, '#text'],ALLOWED_ATTR: attributes,- // Match the native Sanitizer: remove disallowed elements with their content+ // Match the native Sanitizer: strip aria-*/data-* and disallowed element content+ ALLOW_ARIA_ATTR: false,+ ALLOW_DATA_ATTR: false,KEEP_CONTENT: false});}}```-By default, DOMPurify keeps the text content of elements it removes, while the native Sanitizer removes disallowed elements together with their content. Setting `KEEP_CONTENT: false` and allowing `#text` makes DOMPurify match the native behavior. DOMPurify has no built-in option equivalent to `replaceWithChildrenElements`, so avoid that option in configurations that need a matching fallback.+By default, DOMPurify keeps `aria-*` and `data-*` attributes (even when `ALLOWED_ATTR` is specified) as well as the text content of elements it removes, while the native Sanitizer strips `aria-*` and `data-*` attributes and removes disallowed elements together with their content. Setting `ALLOW_ARIA_ATTR: false`, `ALLOW_DATA_ATTR: false`, `KEEP_CONTENT: false`, and allowing `#text` makes DOMPurify match the native behavior. DOMPurify has no built-in option equivalent to `replaceWithChildrenElements`, so avoid that option in configurations that need a matching fallback.If the page enforces Trusted Types (`require-trusted-types-for 'script'`), assigning a string to `innerHTML` throws. `setHTML()` does not need a Trusted Types policy, but the fallback does: pass `RETURN_TRUSTED_TYPE: true` to `DOMPurify.sanitize()` and allow its `dompurify` policy name in your `trusted-types` CSP directive.diff --git a/skills/modern-web-guidance/guides/security/trusted-types.md b/skills/modern-web-guidance/guides/security/trusted-types.mdindex 9fed33c..99e01df 100644--- a/skills/modern-web-guidance/guides/security/trusted-types.md+++ b/skills/modern-web-guidance/guides/security/trusted-types.md@@ -15,16 +15,16 @@ To use Trusted Types, follow four main steps:### 1. Creating a Policy-A policy is a set of rules for sanitizing content. You create it using `trustedTypes.createPolicy()`.+A policy is a set of rules for sanitizing content. You create it using `trustedTypes.createPolicy()`, typically delegating to a sanitizer library such as DOMPurify or your application's HTML escaping rules:```javascript-const myPolicy = trustedTypes.createPolicy('my-no-pretzel-policy', {- createHTML: (input) => {- // A simple replacement rule.- // In a real app, you might use the Sanitizer API, or a library like DOMPurify.- return input- .replace(/pretzel/g, "popcorn");- }+import DOMPurify from 'dompurify';++const myPolicy = trustedTypes.createPolicy('sanitize-html', {+ createHTML: (input) =>+ // Return a sanitized string; createPolicy() wraps it in a TrustedHTML object.+ // Example using DOMPurify:+ DOMPurify.sanitize(input, { RETURN_TRUSTED_TYPE: false }),});```@@ -33,14 +33,14 @@ const myPolicy = trustedTypes.createPolicy('my-no-pretzel-policy', {Instead of passing a string directly to a sink, you call the policy's creation method.```javascript-const untrustedInput = 'I love eating a soft pretzel.';+const untrustedInput = '<p>Hello, <strong>world</strong>!</p><img src="x" onerror="alert(1)">';// In an enforced environment, this would throw a TypeError:// element.innerHTML = untrustedInput;-// This returns a TrustedHTML object:+// This returns a TrustedHTML object with unsafe elements and attributes removed:const cleanHTML = myPolicy.createHTML(untrustedInput);-// Result: "I love eating a soft popcorn."+// Result: "<p>Hello, <strong>world</strong>!</p><img src=\"x\">"```### 3. Transitioning sinks to use Trusted Types@@ -51,22 +51,22 @@ Update each instance where you write to a sink to first convert it to a TrustedtrustedTypes.createPolicy("default", {createHTML(value) {console.warn("String passed instead of Trusted Type.");- return sanitize(value);+ return DOMPurify.sanitize(value, { RETURN_TRUSTED_TYPE: false });},});```Common sinks that support Trusted Types include:-- **HTML:** `element.innerHTML`, `element.outerHTML`, `document.write()`, `element.setHTMLUnsafe()`, `document.parseHTMLUnsafe()`-- **Script:** `<script src>`, `eval()`-- **ScriptURL:** `Worker()`, `SharedWorker()`+- **HTML:** `element.innerHTML`, `element.outerHTML`, `document.write()`, `element.setHTMLUnsafe()`, `Document.parseHTMLUnsafe()`+- **Script:** `<script>` text content, `eval()`+- **ScriptURL:** `<script src>`, `Worker()`, `SharedWorker()````javascript// Assign the TrustedHTML object.element.innerHTML = cleanHTML;```-Note that the "safe" HTML sanitization methods (`element.setHTML()` and `document.parseHTML()`, for instance), do not support Trusted Types, as they always sanitize potential XSS attacks.+Note that the "safe" HTML sanitization methods (`element.setHTML()` and `Document.parseHTML()`, covered in `sanitize-untrusted-html` (via `npx -y modern-web-guidance@latest retrieve "sanitize-untrusted-html"`)), do not require a Trusted Types policy, as they always sanitize potential XSS attacks natively.### 4. Enforcing Trusted Types with CSP@@ -89,13 +89,13 @@ Trusted Types should be rolled out incrementally to avoid breaking your applicatContent-Security-Policy: require-trusted-types-for 'script';```-You can also restrict which policies are allowed to be created:+You can also restrict which policies are allowed to be created (include `dompurify` if your policy delegates to `DOMPurify.sanitize()`, which internally creates a `dompurify` policy, and `default` if you register a default policy during migration):```http-Content-Security-Policy: trusted-types my-no-pretzel-policy;+Content-Security-Policy: require-trusted-types-for 'script'; trusted-types sanitize-html dompurify;```-With this CSP in place, any writes to a sink that don't use Trusted Types will throw an error. In addition, attempting to create a Trusted Type with a name that isn't `my-no-pretzel-policy` will throw an error.+With this CSP in place, any writes to a sink that don't use Trusted Types will throw an error. In addition, attempting to create a Trusted Type policy with a name not listed in `trusted-types` will throw an error.You can also set this CSP as a `<meta>` tag in your document's `<head>`, although this is potentially less secure.@@ -103,7 +103,7 @@ You can also set this CSP as a `<meta>` tag in your document's `<head>`, althoug<!-- First child of `<head>`, as earlier tags will not enforce this CSP. --><metahttp-equiv="Content-Security-Policy"- content="require-trusted-types-for 'script'; trusted-types my-no-pretzel-policy;"+ content="require-trusted-types-for 'script'; trusted-types sanitize-html dompurify;"/>```diff --git a/skills/modern-web-guidance/guides/security/validate-origins.md b/skills/modern-web-guidance/guides/security/validate-origins.mdindex 174f5f4..67bfa0e 100644--- a/skills/modern-web-guidance/guides/security/validate-origins.md+++ b/skills/modern-web-guidance/guides/security/validate-origins.md@@ -128,7 +128,7 @@ export function handleSandboxedWidgetMessage(event, expectedWidgetWindow) {## Fallback strategyBrowser support for Origin: Limited availability.-Supported by: Chrome 145 (Feb 2026), Edge 145 (Feb 2026), and Safari 26.5.+Supported by: Chrome 145 (Feb 2026), Edge 145 (Feb 2026), and Safari 26.5 (May 2026).Unsupported in: Firefox.If your Baseline target includes browsers that do not yet support the `Origin` interface, feature-detect `'Origin' in globalThis` and fall back to parsing URLs with `new URL()`: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 e5f44bb..baebe5e 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@@ -55,8 +55,9 @@ To prevent the panel from being cut off at the edge of the screen, define "try t/*If the panel overflows the bottom, flip it to the top (flip-block).If it overflows the inline edges, flip it horizontally (flip-inline).+ If it overflows both (e.g., in a corner), flip on both axes (flip-block flip-inline).*/- position-try-fallbacks: flip-block, flip-inline;+ position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;}```@@ -121,11 +122,11 @@ For some use cases, you may be able to use the `@oddbird/css-anchor-positioning`.panel {/* Mandatory: use explicit anchor name */position-anchor: --kebab-anchor;- /* Mandatory: use insets rather that position-area for positioning */+ /* Mandatory: use insets rather than position-area for positioning */bottom: auto;right: auto;top: anchor(bottom);left: anchor(left);margin: 0;}-```\ No newline at end of file+```diff --git a/skills/modern-web-guidance/guides/ui-behaviors/dynamic-sibling-animations.md b/skills/modern-web-guidance/guides/ui-behaviors/dynamic-sibling-animations.mdindex 7894400..3a34759 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/dynamic-sibling-animations.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/dynamic-sibling-animations.md@@ -30,7 +30,7 @@ Use the `sibling-index()` property on the `animation-delay` property so that the## Fallback strategiesBaseline status for sibling-count() and sibling-index(): Newly available. It's been Baseline since 2026-08-18.-Supported by: Chrome 138 (Jun 2025), Edge 138 (Jun 2025), Firefox 154, and Safari 26.2 (Dec 2025).+Supported by: Chrome 138 (Jun 2025), Edge 138 (Jun 2025), Firefox 154 (Aug 2026), and Safari 26.2 (Dec 2025).Test for support for `sibling-index()` using CSS with `@supports (animation-delay: calc(sibling-index() * 0.1s)){}` or JavaScript with `!CSS.supports('animation-delay: calc(sibling-index() * 0.1s)')`.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 5c76a06..6fd4bff 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,28 +49,40 @@ The start and end delay for an interest invoker (i.e. the element with the `inte### Fallback strategies+### Fallbacks & browser support for Interest invokers+Browser support for Interest invokers: Limited availability.Supported by: Chrome 142 (Oct 2025) and Edge 142 (Oct 2025).Unsupported in: Firefox and Safari.-Interest invokers must be conditionally polyfilled using the `interestfor` polyfill package from NPM. Do prefer bundling the polyfill over using the CDN.+Interest invokers must be conditionally polyfilled using the `interestfor` polyfill package from NPM. Prefer bundling the polyfill over using the CDN.++**MANDATORY:** Feature detect by checking for the `interestForElement` property on `HTMLButtonElement.prototype`, and load the polyfill **only** when native support is missing.```html<script type="module">- if(!HTMLButtonElement.prototype.hasOwnProperty("interestForElement")){+ if (!HTMLButtonElement.prototype.hasOwnProperty("interestForElement")) {// CDN link only used for example, prefer bundling.await import("https://unpkg.com/interestfor@latest");}</script>```-When using the polyfill the CSS API changes slightly for the `:interest-source` and `:interest-target` pseudo-classes, as well as, the `interest-delay`, `interest-delay-start`, and `interest-delay-end` properties:+### CSS Polyfill Caveats++When using the polyfill, the CSS API changes slightly to account for the lack of native pseudo-class and property support:++- **Pseudo-classes:** The polyfill cannot define real `:interest-source` and `:interest-target` pseudo-classes, so it applies `.interest-source` and `.interest-target` classes instead. **MANDATORY:** Combine them with `:is()` to support both native and polyfilled states.```css/* Styles to apply when the effect is being previewed */-:is(:interest-source, .interest-source) {}-:is(:interest-target, .interest-target) {}+:is(:interest-source, .interest-source) { /* ... */ }+:is(:interest-target, .interest-target) { /* ... */ }+```++- **CSS Properties:** For `interest-delay`, `interest-delay-start`, and `interest-delay-end`, the polyfill requires using CSS variables as it cannot read the custom properties directly in all browsers.+```css/* Adjust the start and end delay for interest invokers */[interestfor] {--interest-delay-start: 0.2s;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 c66045c..fe4145a 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@@ -30,11 +30,11 @@ The trigger must have a visual indicator to indicate that there is additional in### Accessibility built in to `interestfor`-`interestfor` handles the assistive-technology wiring for you, so you generally do not need to add ARIA attributes manually:+When you use `interestfor`, the browser handles the assistive-technology wiring for you:-- A target with `popover="hint"` gains an implicit minimum role of `tooltip`. **DO NOT** set `role="tooltip"` yourself.-- The browser implicitly associates the source element with the target via `aria-describedby` when the target is plaintext, or via `aria-details` when the target contains interactive content. **DO NOT** add `aria-describedby` or `aria-details` to the trigger.-- Because the association switches to `aria-details` when needed, the target IS allowed to contain interactive content (e.g. a link inside an "interest card").+- **Implicit semantics:** A target with `popover="hint"` gains an implicit minimum role of `tooltip`. **DO NOT** set `role="tooltip"` yourself.+- **Implicit association:** The browser implicitly associates the source element with the target via `aria-describedby` when the target is plaintext, or via `aria-details` when the target contains interactive content. **DO NOT** add `aria-describedby` or `aria-details` to the trigger.+- **Interactive content:** Because the association switches to `aria-details` when needed, the target IS allowed to contain interactive content (e.g. a link inside an "interest card").### Accessibility Constraints (WCAG 1.4.13)@@ -73,21 +73,49 @@ Also, the polyfill does not support `position-area` on popovers, so **MANDATORY:### Fallback strategies+### Fallbacks & browser support for Interest invokers+Browser support for Interest invokers: Limited availability.Supported by: Chrome 142 (Oct 2025) and Edge 142 (Oct 2025).Unsupported in: Firefox and Safari.-Interest invokers must be conditionally polyfilled using the `interestfor` polyfill package from NPM. Do prefer bundling the polyfill over using the CDN.+Interest invokers must be conditionally polyfilled using the `interestfor` polyfill package from NPM. Prefer bundling the polyfill over using the CDN.++**MANDATORY:** Feature detect by checking for the `interestForElement` property on `HTMLButtonElement.prototype`, and load the polyfill **only** when native support is missing.```html<script type="module">- if(!HTMLButtonElement.prototype.hasOwnProperty("interestForElement")){+ if (!HTMLButtonElement.prototype.hasOwnProperty("interestForElement")) {// CDN link only used for example, prefer bundling.await import("https://unpkg.com/interestfor@latest");}</script>```+### CSS Polyfill Caveats++When using the polyfill, the CSS API changes slightly to account for the lack of native pseudo-class and property support:++- **Pseudo-classes:** The polyfill cannot define real `:interest-source` and `:interest-target` pseudo-classes, so it applies `.interest-source` and `.interest-target` classes instead. **MANDATORY:** Combine them with `:is()` to support both native and polyfilled states.++```css+/* Styles to apply when the effect is being previewed */+:is(:interest-source, .interest-source) { /* ... */ }+:is(:interest-target, .interest-target) { /* ... */ }+```++- **CSS Properties:** For `interest-delay`, `interest-delay-start`, and `interest-delay-end`, the polyfill requires using CSS variables as it cannot read the custom properties directly in all browsers.++```css+/* Adjust the start and end delay for interest invokers */+[interestfor] {+ --interest-delay-start: 0.2s;+ interest-delay-start: var(--interest-delay-start);+ --interest-delay-end: 0.1s;+ interest-delay-end: var(--interest-delay-end);+}+```+### Fallbacks & browser support for PopoverBaseline status for Popover: Newly available. It's been Baseline since 2025-01-27.@@ -127,7 +155,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.Browser support for popover="hint": Limited availability.-Supported by: Chrome 151, Edge 151, and Firefox 153 (Jul 2026).+Supported by: Chrome 151 (Jul 2026), Edge 151 (Jul 2026), 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.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/motion.md b/skills/modern-web-guidance/guides/ui-behaviors/motion.mdindex a9223ad..b263ad0 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/motion.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/motion.md@@ -63,3 +63,33 @@ progress:not([value]) {--animation-reduced: slide 20s infinite linear;}```++### Working with animation and transition events in JavaScript++On both the `AnimationEvent` (`animationstart`, `animationiteration`, `animationend`, `animationcancel`) and `TransitionEvent` (`transitionrun`, `transitionstart`, `transitionend`, `transitioncancel`) interfaces, `event.target` gives you the originating DOM element. To access the specific `Animation` object (`Animation`, `CSSAnimation`, or `CSSTransition`) that triggered the event, use the readonly `event.animation` property.++When `event.animation` is not available, you can usually find the `Animation` instance by calling `event.target.getAnimations()` and filtering by `event.animationName` (or `event.propertyName` for transitions). However, using `event.animation` directly is preferred, in order to avoid several scenarios where this fallback that filters `event.target.getAnimations()` does not work as expected:++- Web Animations API (`element.animate()`) animations do not have an `animationName`, so they cannot be matched by name when filtering `event.target.getAnimations()`.+- Filtering by `animationName` for `AnimationEvent`s is ambiguous when multiple animations with the same name are attached to the same element.+ - Note that filtering on `transitionProperty` for `TransitionEvent`s works as there is only one event per transition property.+- `event.target` always points to the originating DOM element, so it does not distinguish between animations running on the element itself versus one of its pseudo-elements — whereas `event.animation.effect.pseudoElement` exposes the target pseudo-element directly.++```js+// Works in most basic CSS animation cases, but fails for WAAPI animations,+// duplicate animation names on the same element, or pseudo-elements.+document.addEventListener('animationstart', (event) => {+ const animation = event.target+ .getAnimations()+ .find((anim) => anim.animationName === event.animationName);+ console.log(animation);+});++// PREFERRED: Directly access the exact Animation object via event.animation+document.addEventListener('animationstart', (event) => {+ const animation = event.animation;+ console.log(animation);+});+```++You can feature-detect support using `'animation' in AnimationEvent.prototype` (or `'animation' in TransitionEvent.prototype`).\ No newline at end of filediff --git a/skills/modern-web-guidance/guides/ui-behaviors/prevent-page-scroll-under-modal-dialog.md b/skills/modern-web-guidance/guides/ui-behaviors/prevent-page-scroll-under-modal-dialog.mdnew file mode 100644index 0000000..93bcfbd--- /dev/null+++ b/skills/modern-web-guidance/guides/ui-behaviors/prevent-page-scroll-under-modal-dialog.md@@ -0,0 +1,59 @@+# Prevent the Page Underneath a Modal Dialog from Scrolling++When a `<dialog>` element is opened as a modal using `showModal()`, the browser promotes it to the top layer and marks the rest of the document inert. While that blocks pointer clicks and keyboard focus on the underlying page, it does not prevent scrolling:++1. Scrolling while the pointer or touch gesture is over the `::backdrop` scrolls the page underneath.+2. Scrolling inside the `<dialog>` chains to the underlying page once the dialog reaches its scroll boundary—or immediately if the dialog's content does not overflow.++Per the CSS Overscroll Behavior specification, `overscroll-behavior` applies to **all scroll container elements**, including non-scrollable scroll containers (elements with `overflow: hidden`, or `overflow: auto` whose content does not currently overflow). By combining `overscroll-behavior: contain` on the `<dialog>` with `overflow: hidden` and `overscroll-behavior: contain` on `dialog::backdrop`, you can prevent the underlying page from scrolling using pure CSS.++## Implementation++### 1. Contain scroll chaining on the `<dialog>`++The user-agent stylesheet sets `overflow: auto` on `<dialog>`, making it a scroll container by default. Apply `overscroll-behavior: contain` (or `none`) to `dialog:modal` (or `dialog`).++### 2. Turn `::backdrop` into a scroll container and contain its scroll++By default, `dialog::backdrop` has `overflow: visible`, which means it is **not** a scroll container and ignores `overscroll-behavior`. You must set `overflow: hidden` on `dialog::backdrop` to make it a non-scrollable scroll container, and pair it with `overscroll-behavior: contain` so scroll gestures performed over the backdrop are trapped and do not reach the document underneath.++## Example Code++```css+dialog:modal {+ /* MANDATORY: Prevent scroll gestures inside the modal (even when its content+ does not overflow) from chaining to the underlying page. */+ overscroll-behavior: contain;+}++dialog::backdrop {+ /* MANDATORY: ::backdrop defaults to overflow: visible (not a scroll container).+ Set overflow: hidden so it becomes a non-scrollable scroll container that+ honors overscroll-behavior. */+ overflow: hidden;+ overscroll-behavior: contain;+}+```++## Best Practices & Constraints++- **MANDATORY**: Set `overscroll-behavior: contain` on the `<dialog>` element itself (using the `dialog:modal` selector) and the `dialog::backdrop`. Without this declaration, scroll gestures over the backdrop or inside the dialog will still chain to the page.+- **MANDATORY**: Set `overflow: hidden` (or `overflow: auto`) on `dialog::backdrop` so that it becomes a scroll container. Without this declaration `::backdrop` defaults to `overflow: visible` and `overscroll-behavior` will have no effect.+- **DO NOT** use `overflow: clip` or `overflow: visible` on `dialog::backdrop` or `dialog`. Neither value establishes a scroll container, so `overscroll-behavior` will not apply.+- **DO NOT** apply `overflow: hidden` or `position: fixed` to `<html>` or `<body>` to lock background scrolling when a dialog opens. Mutating root overflow removes the page scrollbar (causing horizontal layout shift), can reset or jump the page scroll position, and can break `position: sticky` elements on the underlying page.++## Fallback Strategies++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.++While the `overscroll-behavior` CSS property is supported across all major browsers for scroll containers that have overflowing content, respecting `overscroll-behavior` on **non-scrollable** scroll containers is a newer specification that cannot be feature detected.++**DO NOT** attempt to feature-detect non-scrollable container support with `@supports (overscroll-behavior: contain)` or `CSS.supports('overscroll-behavior', 'contain')`. All modern browsers support the `overscroll-behavior: contain` property syntax and return `true`, even if they only enforce it when content overflows.++Instead, treat scroll containment on non-scrollable scroll containers as a **progressive enhancement**:++- In browsers that support `overscroll-behavior` on non-scrollable scroll containers, background page scrolling is completely prevented both over `dialog::backdrop` and inside the `<dialog>` (whether or not its content overflows).+- In browsers that do not yet support `overscroll-behavior` on non-scrollable scroll containers, `overscroll-behavior: contain` on `dialog` still prevents scroll chaining whenever the dialog's own content overflows and is scrollable. Meanwhile, `showModal()` still traps keyboard focus and marks the background document `inert`.+- Relying on progressive enhancement is recommended over legacy workarounds that apply `overflow: hidden` or `position: fixed` to `<html>` or `<body>`, because it does not remove the root scrollbar, cause horizontal layout shifts, jump the page scroll position, or break `position: sticky` elements on the underlying page.\ No newline at end of filediff --git a/skills/modern-web-guidance/guides/ui-behaviors/scroll-completion-effects.md b/skills/modern-web-guidance/guides/ui-behaviors/scroll-completion-effects.mdnew file mode 100644index 0000000..3c1ff74--- /dev/null+++ b/skills/modern-web-guidance/guides/ui-behaviors/scroll-completion-effects.md@@ -0,0 +1,97 @@+# Triggering Effects After Programmatic Scrolling Completes++When programmatically scrolling to a section or element (especially with `behavior: 'smooth'`), triggering a follow-up action immediately—such as flashing a highlight state, starting an entry animation, or moving focus—causes the effect to run while the target is still off-screen or mid-scroll.++Previously, developers had to guess the scroll duration with `setTimeout()` (which fires too early on long scrolls and too late on short ones) or manually wrap a `scrollend` event listener in a `Promise` with a fallback timer (because `scrollend` does not fire when the target is already in view and no scrolling occurs).++The programmatic scroll methods on `Element` (`scrollIntoView()`, `scroll()`, `scrollTo()`, `scrollBy()`) and `Window` (`scroll()`, `scrollTo()`, `scrollBy()`) return a `Promise` that resolves when the scroll operation completes. If the target is already at the requested scroll position and no scrolling is needed, the returned `Promise` resolves immediately without hanging.++## Implementation++1. **Mark the handler as `async`**: Use an `async` function for the event listener or navigation handler that triggers the scroll.+2. **Await the scroll method directly**: Call `await element.scrollIntoView({ behavior: 'smooth', ... })` (or `await element.scrollTo(...)`, `await window.scrollTo(...)`, etc.). Execution pauses until the browser finishes the scroll animation and the scroll position settles.+3. **Apply the post-scroll effect**: Toggle the highlight class, start the animation, or move focus after the `await` expression completes.++## Interrupted Scrolls & Focus Management++- **Handling rapid / interrupted scrolls**: If a new scroll starts on the same scroll container before an ongoing smooth scroll finishes, the browser aborts the ongoing smooth scroll and **resolves** (does not reject) all pending scroll promises on that container. If you need to suppress the post-scroll effect for superseded scrolls when a user clicks rapidly, track an incrementing operation ID and return early after `await` if a newer scroll was started:++```javascript+let currentScrollId = 0;+const sections = document.querySelectorAll('section');++async function scrollToAndHighlight(targetElement) {+ const scrollId = ++currentScrollId;+ sections.forEach((sec) => sec.classList.remove('highlight'));++ await targetElement.scrollIntoView({ behavior: 'smooth', block: 'center' });++ // Abort follow-up effect if another scroll was triggered while awaiting+ if (scrollId !== currentScrollId) return;++ targetElement.classList.add('highlight');+}+```++- **Focusing the target after scrolling**: When moving keyboard focus to the target element (or a heading inside it with `tabindex="-1"`) after `await targetElement.scrollIntoView(...)`, pass `{ preventScroll: true }` to `focus()` so the focus call does not initiate a second, competing scroll:++```javascript+await targetElement.scrollIntoView({ behavior: 'smooth', block: 'center' });+targetHeading.focus({ preventScroll: true });+```++## Constraints & Best Practices++- **MANDATORY**: Await the `Promise` returned directly by `scrollIntoView()`, `scroll()`, `scrollTo()`, or `scrollBy()` rather than guessing scroll durations with `setTimeout()`.+- **DO NOT** wrap `scrollend` in a manual `new Promise()` as your primary implementation—`scrollend` does not fire when the target is already in view and no scroll distance is traveled, whereas scroll method promises resolve automatically in that case.+- **DO**: Pass `{ preventScroll: true }` when calling `.focus()` after awaiting a scroll method so the browser does not jump or scroll a second time.+- **DO**: Guard post-scroll effects with a request token if rapid user interactions can trigger overlapping smooth scrolls on the same container, since interrupting a smooth scroll resolves (rather than rejects) the previous promise.+- **Known Chrome bug with the root scroller**: Chrome has a bug where the `Promise` returned by `scrollIntoView()` resolves too early when it is the document's root scroller that is scrolling. Awaiting a `scrollIntoView()` on a nested scroll container works as expected. Do not wrap your content in a scroll container, such as `div` with `overflow-y: auto`, as a workaround for this bug.++## Fallback strategies++Browser support for Scroll method promises: Limited availability.+Supported by: Chrome 150 (Jun 2026) and Edge 150 (Jul 2026).+Unsupported in: Firefox and Safari.++In browsers that do not support scroll method promises, `scrollIntoView()`, `scroll()`, `scrollTo()`, and `scrollBy()` return `undefined` instead of a `Promise`.++- **Progressive enhancement (default `await` behavior)**: Because `await undefined` is valid JavaScript that resolves immediately on the next microtask, writing `await element.scrollIntoView({ behavior: 'smooth' })` will not throw an error in unsupported browsers. Instead, it degrades gracefully by running the post-scroll code as soon as the scroll begins. For non-critical visual flourishes like a temporary highlight, this is often sufficient.+- **Faithful fallback (`scrollend` + timeout)**: If your Baseline target does not support `scroll-promises` and the post-scroll action must wait until scrolling finishes in older browsers, check whether the return value is a `Promise` (`result instanceof Promise`). When it is `undefined`, wait for the `scrollend` event on the scroll container with a short fallback timeout in case the element is already in view and no scrolling occurs:++```javascript+function scrollIntoViewAsync(element, options, scroller = window) {+ const result = element.scrollIntoView(options);++ // Feature detect: in supporting browsers, scrollIntoView() returns a Promise+ if (result instanceof Promise) {+ return result;+ }++ // Fallback for browsers where scrollIntoView() returns undefined+ return new Promise((resolve) => {+ let timeoutId;++ const finish = () => {+ clearTimeout(timeoutId);+ scroller.removeEventListener('scrollend', finish);+ scroller.removeEventListener('scroll', onScroll);+ resolve();+ };++ const onScroll = () => {+ // Restart the idle timer on every scroll event. If scrollend never fires+ // (browsers without scrollend support), this resolves once scrolling goes idle.+ clearTimeout(timeoutId);+ timeoutId = setTimeout(finish, 100);+ };++ scroller.addEventListener('scrollend', finish, { once: true });+ scroller.addEventListener('scroll', onScroll, { passive: true });++ // If no scroll event fires within the idle window (e.g., already in view), resolve.+ // 100ms is an example value; it only needs to exceed the gap between scroll events.+ timeoutId = setTimeout(finish, 100);+ });+}+```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 8e82d39..bfab204 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@@ -4,6 +4,8 @@ Swipe-to-remove patterns are common in mobile applications but can be challenginThe same pattern works for any single-action swipe (remove, archive, mark as read, snooze). The action visuals change; the mechanics do not.+> If you instead want a horizontal swipe to snap open a set of action buttons or a side menu **without** automatically committing an action during the swipe, see `swipe-to-reveal` (via `npx -y modern-web-guidance@latest retrieve "swipe-to-reveal"`).+## How to implementThe component has two layers: a **list** (the `<ul>`) and the **items** inside it. Each item is structured as an outer `<li>`, an inner scroll **track** (the scroll container with the snap points), and a **content** element (the visible row). The action's revealed UI (trash icon, archive label, etc.) lives on either side of the content. The list owns shared wiring (lazy item setup, picking up newly added items); each item owns its own swipe detection.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/swipe-to-reveal.md b/skills/modern-web-guidance/guides/ui-behaviors/swipe-to-reveal.mdnew file mode 100644index 0000000..13a7204--- /dev/null+++ b/skills/modern-web-guidance/guides/ui-behaviors/swipe-to-reveal.md@@ -0,0 +1,164 @@+# Swipe to reveal++Swipe-to-reveal patterns let users slide a foreground row or content pane horizontally to expose hidden UI—such as contextual action buttons (*Pin*, *Mute*, *Archive*, *Delete*) or a secondary side menu—**without automatically activating any action**. Instead of committing an action during the swipe, the container snaps open to reveal interactive controls that the user can inspect and activate, or swipe back to close.++> For a full-width swipe gesture that immediately commits and dismisses an item past a threshold, see `swipe-to-remove` (via `npx -y modern-web-guidance@latest retrieve "swipe-to-remove"`). For revealing a hidden header at the top of a vertical scroll container, see `pull-to-reveal` (via `npx -y modern-web-guidance@latest retrieve "pull-to-reveal"`).++## How to implement++Whether you are revealing action buttons on a list item or a side menu next to a scrollable pane, the mechanics are identical: wrap the foreground content and the hidden panel inside an outer horizontal scroll container configured with **CSS Scroll Snap** (`scroll-snap-type: x mandatory`) and **`overscroll-behavior: chain`**. The browser's native scrolling engine handles momentum, snapping, keyboard focus scrolling, and scroll chaining without JavaScript gesture listeners.++### Step 1: Mark up the swipe wrapper, content, and revealed panel++Place the foreground content first and the revealed controls (action buttons or a side menu) second inside the `.SwipeReveal` scroll container. Because the content is first in DOM order, the scroll container naturally starts at scroll offset `0` with the panel hidden off-screen to the right.++```html+<!-- Example A: List item with revealable action buttons -->+<div class="SwipeReveal">+ <div class="SwipeReveal-content">+ <strong>Design review notes</strong>+ <p>Updated component specs for the Q3 release.</p>+ </div>+ <div class="SwipeReveal-panel" role="group" aria-label="Item actions">+ <button type="button">Pin</button>+ <button type="button">Archive</button>+ <button type="button">Delete</button>+ </div>+</div>++<!-- Example B: Scrollable content pane with a revealable side menu -->+<div class="SwipeReveal" role="region" aria-label="Document preview with swipeable side menu">+ <div class="SwipeReveal-content is-scrollable" tabindex="0">+ <h2>Article Preview</h2>+ <p>Scroll vertically through this pane, or swipe left to reveal the side menu...</p>+ </div>+ <nav class="SwipeReveal-panel" aria-label="Contextual menu">+ <a href="#share">Share</a>+ <a href="#bookmark">Bookmark</a>+ <a href="#export">Export PDF</a>+ </nav>+</div>+```++### Step 2: Configure the horizontal snap container and `overscroll-behavior: chain`++When you wrap an element in an outer scroll container solely to create a swipe-to-reveal effect, that outer wrapper becomes an intermediate scroller inside the document (or another parent scroll container).++The four keywords of `overscroll-behavior` independently control whether excess scroll propagates to an ancestor scroll container (**scroll chaining**) and whether the container displays local overscroll affordances such as elastic rubber-band stretching or edge glow (**local boundary effect**):++| Value | Scroll Chaining (Propagates to Ancestor) | Local Boundary Effect (Rubber-band / Glow) | Role in Swipe-to-Reveal |+| :--- | :--- | :--- | :--- |+| `auto` | Yes | Yes | Default behavior; keep this on inner content scrollers where normal bounce feedback is desired, but avoid on the outer swipe wrapper where it causes the menu to bounce |+| `chain` | **Yes** | **No** | **Use on the outer `.SwipeReveal` scroller so excess scroll chains into the parent scroller (such as the document) without the menu or action strip bouncing** |+| `contain` | No | Yes | Traps scroll inside the container while still bouncing locally |+| `none` | No | No | Blocks both local bounce and scroll chaining to ancestors |++Make `.SwipeReveal` a two-column grid (`grid-template-columns: 100% max-content`) where `.SwipeReveal-content` snaps to `start` and `.SwipeReveal-panel` snaps to `end`:++```css+.SwipeReveal {+ /* Column 1: full-width content. Column 2: auto-sized actions or side menu. */+ display: grid;+ grid-template-columns: 100% max-content;+ overflow-x: auto;+ scroll-snap-type: x mandatory;+ scrollbar-width: none;++ /* Prevent the swipe wrapper and revealed panel from bouncing locally while+ still chaining excess scroll into the parent scroller (the document). */+ overscroll-behavior: chain;+}++@media (prefers-reduced-motion: no-preference) {+ .SwipeReveal {+ scroll-behavior: smooth;+ }+}++.SwipeReveal-content {+ scroll-snap-align: start;+ scroll-initial-target: nearest;+ background: Canvas;+}++.SwipeReveal-content:focus-visible {+ outline: auto;+ outline-offset: -2px;+}++.SwipeReveal-content.is-scrollable {+ block-size: 20rem;+ overflow: auto;+ /* Keeps default `overscroll-behavior: auto` so the content pane retains+ its normal bounce effect while chaining horizontal swipes to `.SwipeReveal`. */+}++.SwipeReveal-panel {+ /* Snapping a trailing panel to `end` (or a leading panel to `start`) brings+ all controls fully into view while keeping the adjacent edge of the content visible. */+ scroll-snap-align: end;+ display: flex;++ &:first-child {+ scroll-snap-align: start;+ }+}+```++> If you also want to reveal controls on the left (`inline-start`) side using three columns (`grid-template-columns: max-content 100% max-content`) or two columns (`max-content 100%`), place the leading `.SwipeReveal-panel` before `.SwipeReveal-content`. Because `.SwipeReveal-content` has `scroll-initial-target: nearest`, the scroll container initially rests on the content column rather than the leading panel.++### Step 3: Snap focusable content panes back into view on keyboard focus++Because the buttons or links inside `.SwipeReveal-panel` are off-screen at rest, tabbing into them with a keyboard automatically scrolls `.SwipeReveal` to reveal the focused control. However, because `.SwipeReveal-content` spans `100%` of the outer container's width, most of it remains inside the scrollport even while the side panel is open—so pressing `Shift+Tab` to move focus back onto `.SwipeReveal-content` (or onto a focusable element inside it) will not automatically scroll the track back to `0`.++Listen for `focusin` on `.SwipeReveal-content` and check `event.target.matches(':focus-visible')` so keyboard focus on the pane or any descendant snaps `.SwipeReveal-content` back to the start without interfering with pointer clicks or touch drags:++```js+for (const content of document.querySelectorAll('.SwipeReveal-content')) {+ content.addEventListener('focusin', (event) => {+ if (event.target.matches(':focus-visible')) {+ content.scrollIntoView({+ block: 'nearest',+ inline: 'start',+ });+ }+ });+}+```++## Best practices and pitfalls++- **DO** use `scroll-snap-type: x mandatory` rather than `proximity`. With `proximity`, a light swipe can leave the action buttons or side menu partially exposed at rest.+- **DO** set `overscroll-behavior: chain` on the outer horizontal swipe-to-reveal scroller (`.SwipeReveal`) so scroll can chain into the parent scroller without the revealed menu or action strip bouncing.+- **DO** leave `overscroll-behavior: auto` (the default) on inner scrollable content panes (`.SwipeReveal-content.is-scrollable`) where you want normal bounce feedback to happen while still chaining horizontal swipes to the outer swipe scroller.+- **DO** implement revealed actions and side-menu items as real focusable DOM controls (`<button>`, `<a>`). When `.SwipeReveal-content` is focusable or contains focusable controls, pair a `focusin` listener with `event.target.matches(':focus-visible')` to call `scrollIntoView({ block: 'nearest', inline: 'start' })` so tabbing back into the content pane closes the side panel without affecting pointer interactions.+- **DO NOT** intercept `wheel`, `touchmove`, or `pointermove` events in JavaScript to manually translate the content or emulate scroll chaining. Main-thread gesture interception blocks compositor-driven scrolling, breaks native scroll momentum, and degrades responsiveness.++## Fallback++Browser support for scroll-initial-target: Limited availability.+Supported by: Chrome 133 (Feb 2025) and Edge 133 (Feb 2025).+Unsupported in: Firefox and Safari.++When a `.SwipeReveal` container places a `.SwipeReveal-panel` on the left (`inline-start`) side before `.SwipeReveal-content`, browsers that do not support `scroll-initial-target: nearest` will initially render at scroll offset `0` with the leading panel exposed.++If your Baseline target does not support `scroll-initial-target`, detect support with `CSS.supports('scroll-initial-target', 'nearest')` and call `scrollTo()` with `behavior: 'instant'` on `load` so containers with a leading panel jump straight to `.SwipeReveal-content` without scrolling the page:+++## Progressive enhancement++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.++Baseline status for Scroll snap: Widely available. It's been Baseline since 2020-01-15.+Supported by: Chrome 69 (Sep 2018), Edge 79 (Jan 2020), Firefox 68 (Jul 2019), and Safari 11 (Sep 2017).++Baseline status for scrollbar-width: Newly available. It's been Baseline since 2024-12-11.+Supported by: Chrome 121 (Jan 2024), Edge 121 (Jan 2024), Firefox 64 (Dec 2018), and Safari 18.2 (Dec 2024).++Treat `overscroll-behavior: chain` and `scrollbar-width: none` as progressive enhancements without JavaScript fallbacks:++- **Automatic CSS cascade fallback**: The initial value of `overscroll-behavior` is `auto`. Browsers that do not yet recognize the `chain` keyword ignore `overscroll-behavior: chain` at parse time and retain `auto`. Because `auto` already allows scroll chaining to ancestor scroll containers, both the swipe-to-reveal gesture and scroll chaining to the parent work across all browsers out of the box; supporting browsers simply suppress the unwanted rubber-band bounce on the outer swipe wrapper.+- **Overriding `contain` or `none`**: If a base stylesheet or utility class sets `overscroll-behavior: contain` or `none`, declare `overscroll-behavior: auto` immediately before `overscroll-behavior: chain` so browsers that do not yet support `chain` still chain scrolling to the parent rather than trapping it.+- **Scrollbar hiding (`scrollbar-width: none`)**: Hiding the horizontal scrollbar track is purely cosmetic; if an older engine ignores `scrollbar-width: none`, the swipe-to-reveal container remains fully functional with a standard scrollbar.diff --git a/skills/modern-web-guidance/guides/ui-components/checkbox.md b/skills/modern-web-guidance/guides/ui-components/checkbox.mdnew file mode 100644index 0000000..a386b8e--- /dev/null+++ b/skills/modern-web-guidance/guides/ui-components/checkbox.md@@ -0,0 +1,135 @@+# Styling Checkboxes++Use semantic, accessible HTML with each checkbox associated with its label, either by nesting the `<input>` inside the `<label>` or by matching the label’s `for` attribute to the input’s `id`.++Modern CSS provides two approaches to styling checkboxes: customize the native appearance with `accent-color`, or override the default presentation with `appearance: none` on the `<input type="checkbox">` element.++## Native customization with `accent-color`++For simple, brand-consistent styling that retains native rendering, keyboard behavior, validation, and operating-system focus indicators, use `accent-color`.++```css+.checkbox-native {+ accent-color: #1a73e8;++ /* Sizing is controlled via relative units */+ inline-size: 1.25em;+ aspect-ratio: 1;+ margin: 0;+ cursor: pointer;+}+```++## Fully custom styling with `appearance: none`++Use `appearance: none` when the design requires control over the checkbox’s+shape, size, states, or indicators. This removes the native visual styling while+leaving the `<input>` as the interactive target.++Set explicit relative sizes for `--checkbox-size` and `--checkbox-icon-size` because `appearance: none` removes the browser’s default dimensions. Keep the icon smaller than the checkbox to provide space for its border and visual padding.++```css+/* Reusable SVG assets */+:root {+ --icon-check: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'></polyline></svg>");+ --icon-dash: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='4.5' stroke-linecap='round' stroke-linejoin='round'><line x1='5' y1='12' x2='19' y2='12'></line></svg>");+}++/* Custom checkbox */+.checkbox-custom {+ --checkbox-size: 1.25em;+ --checkbox-icon-size: 0.7em;++ appearance: none;+ display: inline-grid;+ place-content: center;+ inline-size: var(--checkbox-size);+ aspect-ratio: 1;+ margin: 0;+ border: 2px solid currentColor;+ cursor: pointer;++ &::before {+ content: "";+ inline-size: var(--checkbox-icon-size);+ aspect-ratio: 1;+ background-color: currentColor;+ mask: var(--checkbox-icon) no-repeat center / contain;+ scale: 0;++ @media (prefers-reduced-motion: no-preference) {+ transition: scale 150ms ease;+ }++ @media (forced-colors: active) {+ background-color: CanvasText;+ }+ }++ &:checked {+ --checkbox-icon: var(--icon-check);+ }++ &:indeterminate {+ --checkbox-icon: var(--icon-dash);+ }++ &:is(:checked, :indeterminate)::before {+ scale: 1;+ }++ &:focus-visible {+ outline: 2px solid currentColor;+ outline-offset: 2px;+ }++ &:disabled {+ cursor: not-allowed;+ opacity: 0.5;+ }+}+```+++## The indeterminate state++The indeterminate state cannot be set via an HTML attribute; set the `indeterminate` DOM property in JavaScript (`checkbox.indeterminate = true`) and ensure the `:indeterminate` pseudo-class is visually distinct from both `:checked` and unchecked states:++* **Native (`accent-color`):** Automatically styled by the browser using the element's `accent-color` (no extra `:indeterminate` CSS rule needed).+* **Custom (`appearance: none`):** Swap `--checkbox-icon` to `var(--icon-dash)` on `.checkbox-custom:indeterminate` as shown above.++```js+const selectAll = document.querySelector("#select-all");+selectAll.indeterminate = true;+```++## Accessibility and interaction++- **DO** use `:focus-visible` rather than `:focus` to style focus indicators on custom checkboxes so a distinct outline appears for keyboard navigation without showing on pointer clicks.+- **DO NOT** use `outline: none` or hide focus indicators on checkboxes.+- **DO** ensure the checkbox or its wrapping `<label>` provides an interactive hit target of at least `44px x 44px` while keeping the visual checkbox box sized in relative units:+ ```css+ label {+ display: inline-flex;+ align-items: center;+ gap: 0.65rem;+ min-block-size: 44px;+ cursor: pointer;+ }+ ```+- **DO** provide a `:disabled` style variant that lowers opacity and sets `cursor: not-allowed` to convey inactive states clearly.+++## Fallback strategies++### Fallbacks & browser support for accent-color++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.+Browsers that do not support this property will ignore it and use their default UI colors.+### CSS Masks++Baseline status for Masks: Widely available. It's been Baseline since 2023-12-07.+Supported by: Chrome 120 (Dec 2023), Edge 120 (Dec 2023), Firefox 53 (Apr 2017), and Safari 15.4 (Mar 2022).diff --git a/skills/modern-web-guidance/guides/ui-components/hovercard.md b/skills/modern-web-guidance/guides/ui-components/hovercard.mdnew file mode 100644index 0000000..ca1eb7a--- /dev/null+++ b/skills/modern-web-guidance/guides/ui-components/hovercard.md@@ -0,0 +1,279 @@+# Build an interactive hovercard++Hovercards provide an interactive preview of content when a user expresses interest in a link (via hover or focus). This is shown to users before they navigate, and either provides the user with the content they need or helps verify that the link will contain the content they are looking for.++If you need plain-text, non-interactive tooltips rather than structured link previews, see `interest-triggered-tooltips` (via `npx -y modern-web-guidance@latest retrieve "interest-triggered-tooltips"`).++## 1. Triggering the hovercard++Use the **Interest Invokers** API to trigger the hovercard. This ensures the card appears on both hover and focus, and handles accessibility wiring automatically.++- Add the `popover="hint"` attribute to your card container. Use `hint` to avoid closing unrelated popover menus that may be open.+- Add the `interestfor` attribute to the trigger link, pointing to the card's `id`.++```html+<a href="/article" interestfor="article-preview">Article title</a>++<!-- The `id` must match the `interestfor` value on the trigger. -->+<div id="article-preview" popover="hint" class="hovercard">+ <h2>The buzz on hummingbirds</h2>+ <p class="byline">By Delphi Aguilar</p>+ <div>+ <img src="bird.jpg" alt="A vibrant hummingbird">+ <p>Brief summary of the article...</p>+ </div>+</div>+```++You do not need to include an additional link to the content inside of the hovercard, as it is redundant to the triggering link.++### Accessibility built in to `interestfor`++When you use `interestfor`, the browser handles the assistive-technology wiring for you:++- **Implicit semantics:** A target with `popover="hint"` gains an implicit minimum role of `tooltip`. **DO NOT** set `role="tooltip"` yourself.+- **Implicit association:** The browser implicitly associates the source element with the target via `aria-describedby` when the target is plaintext, or via `aria-details` when the target contains interactive content. **DO NOT** add `aria-describedby` or `aria-details` to the trigger.+- **Interactive content:** Because the association switches to `aria-details` when needed, the target IS allowed to contain interactive content (e.g. a link inside an "interest card").++## 2. Positioning with Anchor Positioning++Position the hovercard relative to its trigger using **CSS Anchor Positioning**. When using `interestfor`, the trigger becomes an implicit anchor for the popover.++```css+[popover].hovercard {+ /* Position the card below the trigger, aligned with its inline-start edge+ and spanning toward the inline-end, flipping if it overflows the viewport. */+ position-area: block-end span-inline-end;+ position-try-fallbacks: flip-block, flip-inline;+}+```++## 3. Animating entry and exit++By default, interest is shown and lost for keyboard and mouse users with a delay of half a second. This prevents the targeted popover from opening while tabbing through a page or moving your mouse around, and from closing while moving your mouse from the trigger to the popover. To adjust the timing, use the `interest-delay` CSS property.++```css+[interestfor]{+ /* Shorthand for interest-delay-start and interest-delay-end */+ interest-delay: 0.2s 0.1s;+}+```++If users are likely to move through multiple triggers in quick succession, set the initial delay to `0s` if an interest-triggered popover is already open.++```css+:root:has(:interest-source) [interestfor] {+ interest-delay-start: 0s;+}+```++Use `@starting-style` to define the entry animation and `transition-behavior: allow-discrete` (along with `display` and `overlay`) to animate the exit from the top layer, gating the transitions behind `@media (prefers-reduced-motion: no-preference)`.++```css+[popover].hovercard {+ opacity: 0;+ transform-origin: top;+}++[popover].hovercard:popover-open {+ opacity: 1;+ transform: translateY(0) scale(1);+}++@starting-style {+ [popover].hovercard:popover-open {+ opacity: 0;+ transform: translateY(-10px) scale(0.95);+ }+}++/* MANDATORY: Respect user preference for reduced motion by selectively applying transitions. */+@media (prefers-reduced-motion: no-preference) {+ [popover].hovercard {+ transition:+ opacity,+ transform,+ display,+ overlay;+ transition-duration: 0.4s;+ transition-behavior: allow-discrete;+ }+}+```++## 4. OPTIONAL: Seamlessly morphing to the next page++You can optionally use **Cross-Document View Transitions** to create a seamless "morph" animation between the hovercard and the destination page. See `consistent-cross-document-transitions` (via `npx -y modern-web-guidance@latest retrieve "consistent-cross-document-transitions"`) for guidance on implementation.++By assigning matching `view-transition-name` values to elements in the hovercard and their counterparts on the next page, the browser will animate them across the navigation. You can name multiple elements (e.g. titles, images, bylines) to create a complex, multi-element morphing effect. Assign the `view-transition-name` to elements on the open popover using `:popover-open`, to avoid creating duplicate `view-transition-name`s or requiring link-specific `view-transition-name`s.++```css+/* Opt-in to cross-document transitions on both pages */+@view-transition {+ navigation: auto;+}++/* Don't show transitions when loading this page */+::view-transition-group(*) {+ animation-duration: 0s;+}++/* Assign names ONLY when the popover is open to ensure only the correct elements are selected. */+[popover]:popover-open {+ view-transition-name: --hovercard;+ view-transition-class: morph;++ h2 {+ view-transition-name: --title;+ view-transition-class: morph;+ }++ img {+ view-transition-name: --image;+ view-transition-class: morph;+ }+}+```++**MANDATORY:** To ensure the transition is stable and doesn't flicker, the destination page should use `blocking="render"` and `<link rel="expect">` to wait for critical content to be parsed before rendering the first frame.++```html+<!-- On the destination page: -->+<head>+ <!-- Block rendering until the hero image and title are parsed,+ ensuring the view transition snapshot is taken at the right time. -->+ <link rel="expect" href="#main-content" blocking="render">+</head>+<body>+ <main id="main-content">+ <h1>The buzz on hummingbirds</h1>+ <img src="bird.jpg">+ </main>+</body>+```++```css+/* On the destination page: */+main {+ view-transition-name: --hovercard;+ view-transition-class: morph;+}+h1 {+ view-transition-name: --title;+ view-transition-class: morph;+}+img {+ view-transition-name: --image;+ view-transition-class: morph;+}++/* By default no transition */+::view-transition-group(*) {+ animation-duration: 0s;+}+/* Short transition for morphing elements */+::view-transition-group(.morph) {+ animation-duration: 0.4s;+}+/* Disable transition if no `old` view */+::view-transition-new(.morph):only-child {+ animation-duration: 0s;+}+```++## Fallback strategies++Because the trigger is a standard `<a href="...">` link, browsers without support can still navigate on click if you choose to treat the hovercard as a progressive enhancement. When cross-browser hovercard support is required, conditionally load polyfills as needed.++### Fallbacks & browser support for Popover++Baseline 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).++The Popover API is mostly **progressive enhancement**, but its defining behaviors — top-layer promotion, light-dismiss, and `popovertarget` invocation — have no CSS-only equivalent. Older browsers need a polyfill, or a manual fallback if you would rather not ship one.++**Polyfill:** To support the `popover` attribute in older browsers, conditionally load [`@oddbird/popover-polyfill`](https://github.com/oddbird/popover-polyfill). **MANDATORY:** Feature detect by checking for the `popover` property on `HTMLElement.prototype`, and load the polyfill **only** when native support is missing — do NOT load it unconditionally.++With a bundler or import map:++```js+// MANDATORY: Feature detect 'popover' on HTMLElement.prototype.+if (!("popover" in HTMLElement.prototype)) {+ import("@oddbird/popover-polyfill");+}+```++Without a bundler, import from a CDN inside a `<script type="module">`:++```html+<script type="module">+ if (!("popover" in HTMLElement.prototype)) {+ import("https://unpkg.com/@oddbird/popover-polyfill@latest/dist/popover.min.js");+ }+</script>+```++**Styling caveat:** The polyfill cannot define the real `:popover-open` pseudo-class, so it applies a `.\:popover-open` class instead. **MANDATORY:** Combine the two with `:is()` or `:where()`, otherwise browsers that lack `:popover-open` discard the entire rule:++```css+[popover]:is(:popover-open, .\:popover-open) {+ display: block;+}+```++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.++Browser support for popover="hint": Limited availability.+Supported by: Chrome 151 (Jul 2026), Edge 151 (Jul 2026), and Firefox 153 (Jul 2026).+Unsupported in: Safari.++### Fallbacks & browser support for Interest invokers++Browser support for Interest invokers: Limited availability.+Supported by: Chrome 142 (Oct 2025) and Edge 142 (Oct 2025).+Unsupported in: Firefox and Safari.++Interest invokers must be conditionally polyfilled using the `interestfor` polyfill package from NPM. Prefer bundling the polyfill over using the CDN.++**MANDATORY:** Feature detect by checking for the `interestForElement` property on `HTMLButtonElement.prototype`, and load the polyfill **only** when native support is missing.++```html+<script type="module">+ if (!HTMLButtonElement.prototype.hasOwnProperty("interestForElement")) {+ // CDN link only used for example, prefer bundling.+ await import("https://unpkg.com/interestfor@latest");+ }+</script>+```++### CSS Polyfill Caveats++When using the polyfill, the CSS API changes slightly to account for the lack of native pseudo-class and property support:++- **Pseudo-classes:** The polyfill cannot define real `:interest-source` and `:interest-target` pseudo-classes, so it applies `.interest-source` and `.interest-target` classes instead. **MANDATORY:** Combine them with `:is()` to support both native and polyfilled states.++```css+/* Styles to apply when the effect is being previewed */+:is(:interest-source, .interest-source) { /* ... */ }+:is(:interest-target, .interest-target) { /* ... */ }+```++- **CSS Properties:** For `interest-delay`, `interest-delay-start`, and `interest-delay-end`, the polyfill requires using CSS variables as it cannot read the custom properties directly in all browsers.++```css+/* Adjust the start and end delay for interest invokers */+[interestfor] {+ --interest-delay-start: 0.2s;+ interest-delay-start: var(--interest-delay-start);+ --interest-delay-end: 0.1s;+ interest-delay-end: var(--interest-delay-end);+}+```++Browser support for Anchor positioning: Limited availability.+Supported by: Safari 27.+Unsupported in: Chrome, Edge, and Firefox.++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-components/progress-ring.md b/skills/modern-web-guidance/guides/ui-components/progress-ring.mdindex 9b746a6..c4d42d8 100644--- a/skills/modern-web-guidance/guides/ui-components/progress-ring.md+++ b/skills/modern-web-guidance/guides/ui-components/progress-ring.md@@ -147,7 +147,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.Browser support for background-clip: border-area: Limited availability.-Supported by: Chrome 150, Edge 150, and Safari 18.2 (Dec 2024).+Supported by: Chrome 150 (Jun 2026), Edge 150 (Jul 2026), and Safari 18.2 (Dec 2024).Unsupported in: Firefox.For browsers that don't yet support `background-clip: border-area`, fall back to a `mask-image` to hollow out the center of the `<progress>` element.@@ -163,7 +163,7 @@ For browsers that don't yet support `background-clip: border-area`, fall back to```Browser support for attr(): Limited availability.-Supported by: Chrome 133 (Feb 2025), Edge 133 (Feb 2025), and Firefox 155.+Supported by: Chrome 133 (Feb 2025), Edge 133 (Feb 2025), and Firefox 155 (Sep 2026).Unsupported in: Safari.For browsers that don't support the `attr()` CSS function for any property, use a `MutationObserver` to automatically sync the `value` attribute to the `--value` custom property.diff --git a/skills/modern-web-guidance/guides/ui-components/spinner.md b/skills/modern-web-guidance/guides/ui-components/spinner.mdindex 11fbdaf..46d04de 100644--- a/skills/modern-web-guidance/guides/ui-components/spinner.md+++ b/skills/modern-web-guidance/guides/ui-components/spinner.md@@ -150,7 +150,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.Browser support for background-clip: border-area: Limited availability.-Supported by: Chrome 150, Edge 150, and Safari 18.2 (Dec 2024).+Supported by: Chrome 150 (Jun 2026), Edge 150 (Jul 2026), and Safari 18.2 (Dec 2024).Unsupported in: Firefox.For browsers that don't yet support `background-clip: border-area`, fall back to a `mask-image` to hollow out the center.diff --git a/skills/modern-web-guidance/guides/visual-design/dark-mode.md b/skills/modern-web-guidance/guides/visual-design/dark-mode.mdindex 4200277..e87caec 100644--- a/skills/modern-web-guidance/guides/visual-design/dark-mode.md+++ b/skills/modern-web-guidance/guides/visual-design/dark-mode.md@@ -228,7 +228,7 @@ pre, code {### Fallbacks & browser support for light-dark() image valuesBaseline 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.+Supported by: Chrome 150 (Jun 2026), Edge 150 (Jul 2026), 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.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.mdindex 2d920d7..99733d1 100644--- 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.md@@ -58,7 +58,7 @@ Supported by: Chrome 114 (May 2023), Edge 114 (Jun 2023), Firefox 121 (Dec 2023)### For `text-fit`Browser support for text-fit: Limited availability.-Supported by: Chrome 150 and Edge 150.+Supported by: Chrome 150 (Jun 2026) and Edge 150 (Jul 2026).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.