Keep your coding agent up to date with the latest web best practices
Release v0.0.160
github-actions[bot]c573f6c31cc3
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.jsonindex 7d1d810..c4e3403 100644--- a/.claude-plugin/marketplace.json+++ b/.claude-plugin/marketplace.json@@ -8,7 +8,7 @@"name": "modern-web-guidance","source": "./","description": "Keep your coding agent up to date with the latest web best practices",- "version": "0.0.159"+ "version": "0.0.160"}]}diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonindex eae9d92..bf70f6c 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.159",+ "version": "0.0.160","author": {"name": "Google Chrome"}diff --git a/.cursor-plugin/plugin.json b/.cursor-plugin/plugin.jsonindex eae9d92..bf70f6c 100644--- a/.cursor-plugin/plugin.json+++ b/.cursor-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.159",+ "version": "0.0.160","author": {"name": "Google Chrome"}diff --git a/README.md b/README.mdindex ca88e21..cd1a6ac 100644--- a/README.md+++ b/README.md@@ -36,7 +36,7 @@ Here's a tiny sampling of the **128 use-case-centric guides**:* **Accessibility & Security**: accessible error announcements, keyboard focus management.* **Built-in AI**: Leveraging local, on-device client models (native Language Detection, Summarization, and Translation APIs).-#### Full Skill Coverage (v0.0.159)+#### Full Skill Coverage (v0.0.160)<details><summary>Includes expert guidance across <strong>102 modern web features</strong></summary>diff --git a/gemini-extension.json b/gemini-extension.jsonindex eae9d92..bf70f6c 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.159",+ "version": "0.0.160","author": {"name": "Google Chrome"}diff --git a/package.json b/package.jsonindex 031372d..fa37c4b 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.159",+ "version": "0.0.160","publisher": "GoogleChrome","engines": {"vscode": "^1.90.0",diff --git a/skills/modern-web-guidance/guides/css/css.md b/skills/modern-web-guidance/guides/css/css.mdindex 2485c97..55e7192 100644--- a/skills/modern-web-guidance/guides/css/css.md+++ b/skills/modern-web-guidance/guides/css/css.md@@ -428,7 +428,7 @@ Simple pie chart:}```-**Important:** When using gradients to render charts, ensure there is a textual fallback for screen readers.+**Important:** When using gradients to render charts, ensure there is a textual fallback for screen readers. MANDATORY: You MUST provide a semantic data table as an accessible alternative, as detailed in `accessibility` (via `npx -y modern-web-guidance@latest retrieve "accessibility"`) under the alternate text and media guidelines.## 9. Transitions & animationsdiff --git a/skills/modern-web-guidance/guides/forms/animated-select-picker.md b/skills/modern-web-guidance/guides/forms/animated-select-picker.mdindex 8c62c10..7ed987e 100644--- a/skills/modern-web-guidance/guides/forms/animated-select-picker.md+++ b/skills/modern-web-guidance/guides/forms/animated-select-picker.md@@ -28,8 +28,8 @@ The following example demonstrates a custom select styled with standard page ani<selectedcontent></selectedcontent></button><option value="system">- <!-- SVGs are allowed inside options when appearance: base-select is active -->- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <!-- MANDATORY: Decorative inline SVGs MUST set aria-hidden="true" to prevent redundant screen reader announcement -->+ <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="14" rx="2" ry="2"></rect><line x1="8" y1="21" x2="16" y2="21"></line><line x1="12" y1="17" x2="12" y2="21"></line>@@ -37,7 +37,7 @@ The following example demonstrates a custom select styled with standard page aniSystem Default</option><option value="light">- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line>@@ -130,6 +130,20 @@ The following example demonstrates a custom select styled with standard page aniwidth: 1.25rem;height: 1.25rem;}++/* MANDATORY: Provide multiple indicators (e.g. bold font and distinct background) for the checked state to avoid color-only state communication */+.animated-select option:checked {+ font-weight: 700;+ background-color: #f1f5f9;+}++/* Ensure copy-paste safety for users with motion sensitivities */+@media (prefers-reduced-motion: reduce) {+ .animated-select::picker(select),+ .animated-select::picker-icon {+ transition: none !important;+ }+}```## Strategic Implementation & Best Practicesdiff --git a/skills/modern-web-guidance/guides/forms/autofill-highlight-inputs.md b/skills/modern-web-guidance/guides/forms/autofill-highlight-inputs.mdindex 028ac0e..538909d 100644--- a/skills/modern-web-guidance/guides/forms/autofill-highlight-inputs.md+++ b/skills/modern-web-guidance/guides/forms/autofill-highlight-inputs.md@@ -6,21 +6,29 @@ Use the CSS `:autofill` to highlight fields that have (or have not been) autofilTo highlight a form field that has been autofilled by the browser (and not edited by the user) add a selector to your CSS using the `:autofill` class. This can be used for an `<input>`, `<select>`, or `<textarea>` element.-The following example uses `:autofill` to set border color:+When styling autofilled states, you must adhere to accessibility best practices:+- **Multiple State Indicators**: Do not rely on border color alone to indicate the autofilled state. Use multiple indicators such as border thickness and custom background shading to ensure the state is perceivable.+- **Preserve Focus Indicators**: Never remove focus outlines (`outline: none`) without providing a clear, high-contrast replacement for keyboard users.++The following example uses `:autofill` to set a custom border and background, along with explicit focus styles:```cssinput:autofill,-input:-webkit-autofill,-input:-webkit-autofill:hover,-input:-webkit-autofill:focus {- /* box-shadow overrides the autofill background color, which cannot be changed via background-color */- /* box-shadow: 0 0 0 100vmax #efe inset; */- border-color: green;- outline: none;+input:-webkit-autofill {+ /* Multiple indicators: use both a distinct border and background color via box-shadow to avoid color-only state */+ border: 2px solid #2e7d32;+ box-shadow: 0 0 0 100vmax #e8f5e9 inset;+}++/* MANDATORY: Always provide an explicit focus indicator when styling autofilled states */+input:autofill:focus-visible,+input:-webkit-autofill:focus-visible {+ outline: 3px solid #000;+ outline-offset: 2px;}```-As shown in this example, the `box-shadow` property can be used to customize the background if required, since `background-color` cannot be overridden directly.+As shown in this example, the `box-shadow` property is used to customize the background, since `background-color` cannot be overridden directly on autofilled fields.## Use the correct CSS pseudo-class namediff --git a/skills/modern-web-guidance/guides/forms/autofill-payment-form.md b/skills/modern-web-guidance/guides/forms/autofill-payment-form.mdindex 89927f4..da21533 100644--- a/skills/modern-web-guidance/guides/forms/autofill-payment-form.md+++ b/skills/modern-web-guidance/guides/forms/autofill-payment-form.md@@ -87,8 +87,10 @@ Make sure to add appropriate `autocomplete` values in payment card forms. Withoumaxlength="50" pattern="[\p{L} \-\.]+" required><!-- cc-exp autofills the full expiry date as MM/YY -->+<!-- MANDATORY: Place format hints above the input so autocomplete popovers or virtual keyboards do not obscure them during editing -->+<span id="exp-hint" class="hint">Format: MM/YY</span><input id="cc-exp" name="cc-exp" type="text" autocomplete="cc-exp"- placeholder="MM/YY" maxlength="5" required>+ aria-describedby="exp-hint" maxlength="5" required><!-- cc-csc autofills the security code; DO NOT use type="password" here --><input id="cc-csc" name="cc-csc" type="text" autocomplete="cc-csc"@@ -111,7 +113,7 @@ Allow users to include spaces when they're entering a new payment card number, sAdd the `required` attribute to mandatory fields. Modern browsers automatically prompt and set focus for missing data.-### Fallback strategies+## Fallback strategiesBaseline status for enterkeyhint: Widely available. It's been Baseline since 2021-11-02.Supported by: Chrome 77 (Sep 2019), Edge 79 (Jan 2020), Firefox 94 (Nov 2021), Safari 13.1 (Mar 2020), and Safari iOS 13.4 (Mar 2020).diff --git a/skills/modern-web-guidance/guides/forms/brand-consistent-forms.md b/skills/modern-web-guidance/guides/forms/brand-consistent-forms.mdindex b5bd409..df845a4 100644--- a/skills/modern-web-guidance/guides/forms/brand-consistent-forms.md+++ b/skills/modern-web-guidance/guides/forms/brand-consistent-forms.md@@ -35,18 +35,18 @@ body {```html<form><!-- Checkbox -->- <label>- <input type="checkbox" checked>+ <label for="subscribe">+ <input type="checkbox" id="subscribe" checked>Subscribe to newsletter</label><!-- Radio Buttons -->- <label>- <input type="radio" name="plan" value="monthly">+ <label for="plan-monthly">+ <input type="radio" id="plan-monthly" name="plan" value="monthly">Monthly</label>- <label>- <input type="radio" name="plan" value="yearly" checked>+ <label for="plan-yearly">+ <input type="radio" id="plan-yearly" name="plan" value="yearly" checked>Yearly</label>@@ -83,8 +83,8 @@ You MUST use the `@supports not` rule to apply custom fallback styles only when#### 1. HTML StructureEnsure your labels wrap the text in a `<span>` to allow for sibling selectors in CSS:```html-<label>- <input type="checkbox" checked>+<label for="subscribe-fallback">+ <input type="checkbox" id="subscribe-fallback" class="visually-hidden" checked><span>Subscribe to newsletter</span></label>```@@ -94,12 +94,17 @@ Apply custom styles within a `@supports not` block:```css/* Fallback for older browsers without accent-color */@supports not (accent-color: var(--brand-color)) {- /* Visually hide the native input */- form input[type="checkbox"] {- position: absolute;- opacity: 0;- width: 0;- height: 0;+ /* Visually hide the native input using the canonical accessible recipe */+ form input[type="checkbox"].visually-hidden {+ position: absolute !important;+ clip-path: inset(50%) !important;+ overflow: hidden !important;+ width: 1px !important;+ height: 1px !important;+ margin: -1px !important;+ padding: 0 !important;+ border: 0 !important;+ white-space: nowrap !important;}/* Style the wrapper label */@@ -127,6 +132,12 @@ Apply custom styles within a `@supports not` block:transition: all 0.2s ease;}+ /* Ensure custom checkbox shows focus for keyboard users */+ input[type="checkbox"]:focus-visible + span::before {+ outline: 2px solid #000;+ outline-offset: 2px;+ }+/* Checked State */input[type="checkbox"]:checked + span::before {background-color: var(--brand-color, #6200ee);diff --git a/skills/modern-web-guidance/guides/forms/custom-select-picker-layouts.md b/skills/modern-web-guidance/guides/forms/custom-select-picker-layouts.mdindex 2acb04a..f0d2e34 100644--- a/skills/modern-web-guidance/guides/forms/custom-select-picker-layouts.md+++ b/skills/modern-web-guidance/guides/forms/custom-select-picker-layouts.md@@ -62,9 +62,11 @@ To implement a custom select picker layout:border-radius: 6px;}+/* MANDATORY: Use multiple visual indicators (distinct border thickness, background shift, and font weight) for the checked state to avoid color-only state communication */.grid-picker option:checked {- border-color: #007bff;+ border: 2px solid #007bff;background-color: #f0f7ff;+ font-weight: 700;}```@@ -72,7 +74,7 @@ To implement a custom select picker layout:- **DO** use `appearance: base-select` when you need to change the visual layout of options from a standard list to a 2D grid or custom flex flow.- **DO NOT** assume the styles apply to all browsers equally yet; verify support and provide a fallback.-- **DO NOT** confuse visual layout with keyboard navigation. Standard select uses linear navigation. If you arrange options in a grid, ensure visual order matches DOM order so tab/arrow navigation makes sense.+- **MANDATORY Accessibility Routing**: A native `<select>` element enforces one-dimensional linear arrow-key navigation (Up/Down). Arranging options in a 2D visual grid creates a spatial mismatch where pressing Left/Right arrows does not move focus horizontally between adjacent columns. If true two-dimensional keyboard navigation is essential for usability, do not use a native `<select>`; implement a custom ARIA `role="listbox"` composite widget with manual JavaScript matrix-based arrow key navigation instead.- **DO** use `<selectedcontent>` if you want the trigger button to show images or icons from the selected option automatically.- **DO** use standard `value` attributes on options to ensure form submission works exactly as before.- **DO** ensure your `<select>` has a `name` attribute and an associated `<label>`. This ensures that even with a custom UI, the component remains accessible to screen readers and works correctly with standard form submissions.diff --git a/skills/modern-web-guidance/guides/forms/forms.md b/skills/modern-web-guidance/guides/forms/forms.mdindex 2cca3e2..354ead9 100644--- a/skills/modern-web-guidance/guides/forms/forms.md+++ b/skills/modern-web-guidance/guides/forms/forms.md@@ -177,7 +177,7 @@ input {- **DO** use `accent-color` for quick branding of native radios/checkboxes.- **DO** use `appearance: none` for custom dropdown arrows without breaking semantics.- **DO** ensure inputs are clearly visible with adequate border contrast (e.g., `#ccc` or darker on white backgrounds).-- **DO** hide inputs visually using `position: absolute; opacity: 0` (NOT `display: none`) to keep them accessible.+- **DO** hide inputs visually using the canonical `.visually-hidden` recipe (`clip-path: inset(50%)` with 1px dimensions) — NOT `display: none`, which removes them from the accessibility tree.### Code Example@@ -190,10 +190,14 @@ input {<style>.visually-hidden {position: absolute;- opacity: 0;- width: 1rem;- height: 1rem;- z-index: 1;+ clip-path: inset(50%);+ overflow: hidden;+ width: 1px;+ height: 1px;+ margin: -1px;+ padding: 0;+ border: 0;+ white-space: nowrap;}.checkbox-label::before {content: "";@@ -253,22 +257,26 @@ form.addEventListener('submit', (e) => {<h1>Sign up</h1>- <section>+ <div class="form-group"><label for="name">Full name</label><input id="name" name="name" autocomplete="name" required pattern="[\p{L}\.\- ]+">- </section>+ </div>- <section>+ <div class="form-group"><label for="email">Email</label><input id="email" name="email" type="email" autocomplete="username" required>- </section>+ </div>- <section>+ <div class="form-group"><label for="password">Password</label>- <button id="toggle-password" type="button" aria-label="Show password as plain text. Warning: this will display your password on the screen.">Show password</button>+ <button id="toggle-password" type="button" aria-pressed="false" aria-label="Show password" aria-describedby="toggle-warning">+ <img class="icon-eye" src="/icons/eye.svg" alt="" width="20" height="20">+ <img class="icon-eye-off" src="/icons/eye-off.svg" alt="" width="20" height="20">+ </button>+ <span id="toggle-warning" class="visually-hidden">Warning: this will display your password on the screen.</span><input id="password" name="password" type="password" autocomplete="new-password" minlength="8" aria-describedby="password-constraints" required><div id="password-constraints">Eight or more characters.</div>- </section>+ </div><button id="sign-up">Sign up</button></form>diff --git a/skills/modern-web-guidance/guides/forms/required-field-feedback.md b/skills/modern-web-guidance/guides/forms/required-field-feedback.mdindex 4678004..6235172 100644--- a/skills/modern-web-guidance/guides/forms/required-field-feedback.md+++ b/skills/modern-web-guidance/guides/forms/required-field-feedback.md@@ -18,7 +18,7 @@ The `:user-invalid` pseudo-class solves this perfectly. For a required field, it### 1. HTML Structure```html-<form>+<form id="feedback-form"><div class="field"><label for="full-name">Full Name</label><input@@ -28,8 +28,9 @@ The `:user-invalid` pseudo-class solves this perfectly. For a required field, itrequiredaria-errormessage="name-error">+ <!-- MANDATORY: Include an icon or distinct non-color indicator alongside error text --><div id="name-error" class="error-msg">- This field is required.+ <span aria-hidden="true">❌</span> This field is required.</div></div></form>@@ -46,6 +47,7 @@ The `:user-invalid` pseudo-class solves this perfectly. For a required field, it/*Only highlight empty required fields AFTER the user visits them.+ MANDATORY: Provide multiple indicators (border shift + helper text/icon) to avoid color-only state communication.*/input:user-invalid {border-color: #d93025;@@ -63,6 +65,41 @@ input:required:user-valid {}```+### 3. JavaScript State Synchronization++MANDATORY: Because `:user-invalid` is a visual state, you MUST provide a JavaScript bridge to sync `aria-invalid="true"` dynamically for assistive technologies when a user blurs an invalid field or attempts submission.++```javascript+const form = document.getElementById('feedback-form');++const syncAriaInvalid = (input) => {+ if (!input.checkValidity()) {+ input.setAttribute('aria-invalid', 'true');+ } else {+ input.removeAttribute('aria-invalid');+ }+};++// Sync on blur when a user finishes interacting+form.addEventListener('blur', (e) => {+ if (e.target.matches('input[required]')) {+ syncAriaInvalid(e.target);+ }+}, true);++// Sync all required fields when submission is attempted+form.addEventListener('submit', () => {+ form.querySelectorAll('input[required]').forEach(syncAriaInvalid);+});++// Remove error state immediately upon correction+form.addEventListener('input', (e) => {+ if (e.target.matches('input[required]') && e.target.checkValidity()) {+ e.target.removeAttribute('aria-invalid');+ }+});+```+## Fallbacking & Browser Support### Fallbacks & browser support for :user-valid and :user-invaliddiff --git a/skills/modern-web-guidance/guides/forms/rich-media-picker.md b/skills/modern-web-guidance/guides/forms/rich-media-picker.mdindex 15578b3..a0e448a 100644--- a/skills/modern-web-guidance/guides/forms/rich-media-picker.md+++ b/skills/modern-web-guidance/guides/forms/rich-media-picker.md@@ -20,8 +20,9 @@ To implement a rich media picker using the Customizable Select API:<selectedcontent></selectedcontent> <!-- Mirrors the selected option's content automatically so you do not need JS to update the button --></button>- <option value="frontend">- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor">+ <!-- Define concise aria-label values on options whose mirrored rich content would otherwise read awkwardly as a concatenated string -->+ <option value="frontend" aria-label="Frontend Developer">+ <svg aria-hidden="true" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"><rect x="2" y="3" width="20" height="14" rx="2" ry="2"></rect></svg><div class="option-text">@@ -30,8 +31,8 @@ To implement a rich media picker using the Customizable Select API:</div></option>- <option value="backend">- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor">+ <option value="backend" aria-label="Backend Developer">+ <svg aria-hidden="true" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"><rect x="2" y="12" width="20" height="14" rx="2" ry="2"></rect></svg><div class="option-text">@@ -87,6 +88,15 @@ select.custom-select option:hover {select.custom-select option::before {display: none;}++/* MANDATORY: Provide multiple visual indicators (e.g., prominent background color and bold title font) to communicate the checked state cleanly */+select.custom-select option:checked {+ background-color: #3b82f6;+ color: #ffffff;+}+select.custom-select option:checked .option-title {+ font-weight: 700;+}```## Strategic Implementation & Best Practicesdiff --git a/skills/modern-web-guidance/guides/forms/validate-input-after-interaction.md b/skills/modern-web-guidance/guides/forms/validate-input-after-interaction.mdindex a638f98..e880ed2 100644--- a/skills/modern-web-guidance/guides/forms/validate-input-after-interaction.md+++ b/skills/modern-web-guidance/guides/forms/validate-input-after-interaction.md@@ -25,6 +25,8 @@ MANDATORY: Rely on standard HTML5 attributes for email fields. The error message<form><div class="field"><label for="email">Email Address</label>+ <!-- MANDATORY: Place format hints above the input so autocomplete popovers don't cover them during editing -->+ <span id="email-hint" class="hint">Format: [email protected]</span><!-- DO: Use standard HTML validation attributes like type="email" and required --><inputtype="email"@@ -32,17 +34,24 @@ MANDATORY: Rely on standard HTML5 attributes for email fields. The error messagename="email"requiredautocomplete="email"- placeholder="[email protected]"+ aria-describedby="email-hint"aria-errormessage="email-error"><div id="email-error" class="error-msg">- Please enter a valid email address (e.g. [email protected]).+ <span aria-hidden="true">❌</span> Please enter a valid email address.</div></div></form>``````css+.hint {+ display: block;+ color: #5f6368;+ font-size: 0.85rem;+ margin-bottom: 0.25rem;+}+.error-msg {display: none;color: #d93025;@@ -52,7 +61,7 @@ MANDATORY: Rely on standard HTML5 attributes for email fields. The error message/*DO: Only show error styles after user interaction.- This prevents the "angry red border" on page load.+ Use multiple indicators (border/background shift + icon/text) to avoid color-only states.*/input:user-invalid {border-color: #d93025;@@ -64,7 +73,7 @@ input:user-invalid + .error-msg {display: block;}-/* DO: Optionally provide a green success state on :user-valid */+/* DO: Provide a clear success indication on :user-valid */input:user-valid {border-color: #188038;}@@ -72,19 +81,21 @@ input:user-valid {### Use Case 2: Password Complexity-MANDATORY: Define the complexity rule using a Regex Lookahead pattern in the `pattern` attribute. The rules list is shown to guide the user, and highlighted if there's an error.+MANDATORY: Define the complexity rule using a Regex Lookahead pattern in the `pattern` attribute. The rules list is shown above the input to guide the user, and highlighted if there's an error.```html<form><div class="field"><label for="password">New Password</label>+ <!-- MANDATORY: Place hints and rules above the input so mobile keyboards do not obscure them -->+ <ul id="password-rules" class="rules-list">+ <li>At least 8 characters</li>+ <li>One uppercase letter</li>+ <li>One number</li>+ <li>One special character</li>+ </ul><!-- DO: Use pattern and minlength for complex password validationDO: Match all constraints with lookaheads via pattern attribute- (?=.*\d) : Must contain at least one digit- (?=.*[a-z]) : Must contain at least one lowercase letter- (?=.*[A-Z]) : Must contain at least one uppercase letter- (?=.*[\W_]) : Must contain at least one special char- .{8,} : Must be at least 8 chars long--><inputtype="password"@@ -95,20 +106,16 @@ MANDATORY: Define the complexity rule using a Regex Lookahead pattern in the `paminlength="8"aria-describedby="password-rules">- <!-- DO NOT: Hide the rules initially. Users need them to know what to type. -->- <ul id="password-rules" class="rules-list">- <li>At least 8 characters</li>- <li>One uppercase letter</li>- <li>One number</li>- <li>One special character</li>- </ul></div></form>``````css/* DO: State the default styling as neutral */-.rules-list { color: #5f6368; }+.rules-list {+ color: #5f6368;+ margin-bottom: 0.5rem;+}/* DO: Show invalid state (After interaction): Error */input:user-invalid {@@ -116,17 +123,19 @@ input:user-invalid {background-color: #fce8e6;}-/* DO: Highlight rules list when error is shown */-input:user-invalid + .rules-list {+/* DO: Highlight rules list when error is shown using the modern :has() selector */+.field:has(input:user-invalid) .rules-list {color: #d93025;+ font-weight: 600;}/* DO: Add success indications for :user-valid state */input:user-valid {border-color: #188038;}-/* DO: Hide rules or turn them green once satisfied */-input:user-valid + .rules-list {++/* DO: Hide rules once satisfied */+.field:has(input:user-valid) .rules-list {display: none;}```diff --git a/skills/modern-web-guidance/guides/html/html.md b/skills/modern-web-guidance/guides/html/html.mdindex 39f1057..e23f2e4 100644--- a/skills/modern-web-guidance/guides/html/html.md+++ b/skills/modern-web-guidance/guides/html/html.md@@ -352,6 +352,7 @@ See `forms` (via `npx -y modern-web-guidance@latest retrieve "forms"`) for more- **DO** ensure background videos are `muted`, provide users with full control over playback, and use `role="none"` or `aria-hidden="true"`. The `controls` attribute must also be omitted to make sure the video is not focusable.- **DON'T** rely on JS for basic video controls if native `controls` attribute is sufficient.+- **DON'T** apply `role="none"` or `aria-hidden="true"` to focusable elements (such as embedded interactive `<iframe>` components). Hiding elements from the assistive technology tree while leaving them accessible to sequential keyboard navigation violates core accessibility heuristics. The background video exception holds solely because omitting the `controls` attribute renders the `<video>` element fully non-focusable.### Code Examplediff --git a/skills/modern-web-guidance/guides/performance/defer-rendering-heavy-content.md b/skills/modern-web-guidance/guides/performance/defer-rendering-heavy-content.mdindex 64c8ab5..4a8c548 100644--- a/skills/modern-web-guidance/guides/performance/defer-rendering-heavy-content.md+++ b/skills/modern-web-guidance/guides/performance/defer-rendering-heavy-content.md@@ -10,7 +10,7 @@ To optimize rendering, you can utilize the CSS `content-visibility` property and| :--- | :--- | :--- || **1. Below the fold** (Delay initial load) | **`content-visibility: auto`** | Browser automatically offloads layout/paint workload until the container scrolls close to view, keeping standard page load speed frictionless. || **2. Toggle State** (Fast view switching) | **`content-visibility: hidden`** | Skips layout calculations for hidden divs but preserves style containment state, allowing for instantaneous toggling without structural shifts (superior to `display: none`). |-| **3. Searchable & Deferred** (Collapsible specs/FAQ) | **`hidden="until-found"`** | Same benefits as previous, defers load-time rendering fully, but remains searchable via native Find-in-page. The browser automatically unhides and scrolls to the target on match. |+| **3. Searchable & Deferred** (Collapsible disclosures) | **`hidden="until-found"`** | For detailed instructions on combining rendering performance with find-in-page search accessibility, see `search-hidden-content` (via `npx -y modern-web-guidance@latest retrieve "search-hidden-content"`). |## How to implement `content-visibility: auto`@@ -73,39 +73,13 @@ The `contain-intrinsic-size` CSS shorthand property acts as a placeholder dimens}```-Because `content-visibility: hidden` excludes the element and its children from the accessibility tree and find-in-page search, **DO NOT** use it if the content must remain discoverable while hidden. For searchable hidden content, use `hidden="until-found"`.--## How to implement `hidden="until-found"`--The `hidden="until-found"` attribute forces the browser to apply an internal `content-visibility: hidden` rule. This hides content until a user utilizes "Find in page" or navigates via document fragments directly into the container.--1. **Identify heavy sections:** Locate layout blocks that are initially hidden (e.g., extra rows in a large data table).-2. **Apply the attribute:** Add `hidden="until-found"` directly onto the collapsible container element.-3. **Handle state synchronization:** If reveal states require DOM updates (such as toggling an aria-expanded attribute or rotating a chevron icon), use the `beforematch` event listener.--### Example code--```html-<div class="heavy-section" hidden="until-found">- <p>Heavy content.</p>-</div>-```--```javascript-// Optional: Handle state synchronization-const heavySection = document.querySelector('.heavy-section');--heavySection.addEventListener('beforematch', (event) => {- // Logic to execute immediately before the browser reveals the match-});-```+Because `content-visibility: hidden` excludes the element and its children from the accessibility tree and find-in-page search, **DO NOT** use it if the content must remain discoverable while hidden. If you need hidden content to remain searchable via native Find-in-page, use `hidden="until-found"` as described in `search-hidden-content` (via `npx -y modern-web-guidance@latest retrieve "search-hidden-content"`).## Best Practices- **DO** use `contain-intrinsic-size` with `content-visibility: auto`. Failure to do so forces height recalculations on scroll, causing viewport layout jumping or visual glitches.- **DO NOT** apply `content-visibility: auto` to elements inside the initial fold viewport, as this delays critical page rendering.-- **DO NOT** apply standard `display: none` or `visibility: hidden` to elements designed to use `hidden="until-found"`, as this permanently excludes them from search discovery.-- **DO** verify that `hidden="until-found"` handles interactive states gracefully on trigger.+- **MANDATORY Accessibility Verification**: When applying `content-visibility: auto`, you MUST verify sequential keyboard reachability. In certain assistive technology configurations, off-screen nodes utilizing `content-visibility: auto` may be excluded from the accessibility tree or sequential navigation routes until focus is forcibly moved inside them. Test linear navigation across off-screen boundaries using keyboard alone.## Fallback strategies@@ -130,20 +104,3 @@ When `content-visibility` is not supported it will be ignored by the browser. In}}```--### `hidden="until-found"` fallback--hidden="until-found" has limited availability.-Supported by: Chrome 102 (May 2022), Edge 102 (May 2022), and Firefox 148 (Feb 2026).-Unsupported in: Safari.--When `hidden="until-found"` is not supported elements will remain hidden. Use feature detection targeting `onbeforematch` and extract or reveal content accordingly. Feature detection MUST check for the existence of `onbeforematch` in `HTMLElement.prototype`.--```javascript-if (!('onbeforematch' in HTMLElement.prototype)) {- document.querySelectorAll('[hidden="until-found"]').forEach(el => {- // Unsupported browsers show content to maintain searchability- el.removeAttribute('hidden');- });-}-```diff --git a/skills/modern-web-guidance/guides/user-experience/anchor-positioning-tab-underline.md b/skills/modern-web-guidance/guides/user-experience/anchor-positioning-tab-underline.mdindex 2834248..c6e770d 100644--- a/skills/modern-web-guidance/guides/user-experience/anchor-positioning-tab-underline.md+++ b/skills/modern-web-guidance/guides/user-experience/anchor-positioning-tab-underline.md@@ -65,7 +65,21 @@ ul::before {This is only a visual indicator, and must not be a replacement for setting the appropriate `aria-current="page"` or `aria-selected` aria values.-### Fallback strategies+```html+<!-- MANDATORY: Provide explicit assistive technology state alongside the visual tab underline -->+<nav aria-label="Primary">+ <ul>+ <li class="active">+ <a href="/home" aria-current="page">Home</a>+ </li>+ <li>+ <a href="/about">About</a>+ </li>+ </ul>+</nav>+```++## Fallback strategiesAnchor positioning is not natively supported by any major browser yet.diff --git a/skills/modern-web-guidance/guides/user-experience/animate-to-intrinsic-sizes.md b/skills/modern-web-guidance/guides/user-experience/animate-to-intrinsic-sizes.mdindex 55fde37..fdcf9b8 100644--- a/skills/modern-web-guidance/guides/user-experience/animate-to-intrinsic-sizes.md+++ b/skills/modern-web-guidance/guides/user-experience/animate-to-intrinsic-sizes.md@@ -70,6 +70,32 @@ You can also animate in the opposite direction—starting from a natural size anopacity: 0;pointer-events: none;}++/* MANDATORY Copy-Paste Safety: Disable sizing animations for sensitive users */+@media (prefers-reduced-motion: reduce) {+ .expandable-container,+ .badge,+ .collapsible-alert {+ transition: none !important;+ }+}+```++```javascript+// MANDATORY Accessibility Synchronization: Ensure elements collapsed to zero dimensions are removed from the assistive technology tree, and sync aria-expanded states on triggers.+const alertElement = document.querySelector('.collapsible-alert');+alertElement.addEventListener('transitionend', (e) => {+ if (e.propertyName === 'block-size' && alertElement.classList.contains('is-dismissed')) {+ alertElement.hidden = true;+ }+});++// Example trigger syncer+const triggerBtn = document.querySelector('.accordion-trigger');+triggerBtn?.addEventListener('click', () => {+ const isExpanded = triggerBtn.getAttribute('aria-expanded') === 'true';+ triggerBtn.setAttribute('aria-expanded', !isExpanded);+});```## Key constraintsdiff --git a/skills/modern-web-guidance/guides/user-experience/carousel-snap-highlights.md b/skills/modern-web-guidance/guides/user-experience/carousel-snap-highlights.mdindex d5b916f..59aa4d7 100644--- a/skills/modern-web-guidance/guides/user-experience/carousel-snap-highlights.md+++ b/skills/modern-web-guidance/guides/user-experience/carousel-snap-highlights.md@@ -7,6 +7,17 @@ To highlight snapped items, you must establish a scroll-snap container, define t#### 1. Establish the scroll snap containerThe parent container must have `scroll-snap-type` enabled.+```html+<div class="carousel">+ <div class="carousel-item">+ <div class="card">Product 1 content</div>+ </div>+ <div class="carousel-item">+ <div class="card">Product 2 content</div>+ </div>+</div>+```+```css.carousel {display: flex;@@ -58,6 +69,14 @@ Only show the effect for users not requesting reduced motion. Disable completely}}}++/* MANDATORY Copy-Paste Safety: Disable highlight scaling/flashing for motion sensitive users */+@media (prefers-reduced-motion: reduce) {+ .card {+ transition: none !important;+ scale: 1 !important;+ }+}```The `snapped` descriptor can query specific axes: `x`, `y`, `inline`, `block`, or `both`.@@ -71,7 +90,12 @@ Visual highlights for snapped items can improve the UX, but the snapped item isSnapping occurs due to scrolling, which does not move keyboard focus. However, keyboard focus may cause the scroll container to move, causing a change in the snapped item, which may or may not be the focused item. This will likely be a source of confusion for users and is discouraged.-### Fallback strategies+> [!NOTE]+> Detailed accessibility requirements for carousels (such as ARIA roles, slide attributes, and complex keyboard patterns) have been intentionally omitted from this guide. Carousel accessibility is highly nuanced and context-dependent; refer to established accessibility standards and perform thorough user testing for production environments.+++## Fallback strategies+Container scroll-state queries has limited availability.Supported by: Chrome 133 (Feb 2025) and Edge 133 (Feb 2025).Unsupported in: Firefox and Safari.diff --git a/skills/modern-web-guidance/guides/user-experience/consistent-cross-document-transitions.md b/skills/modern-web-guidance/guides/user-experience/consistent-cross-document-transitions.mdindex 76439c9..6d86d28 100644--- a/skills/modern-web-guidance/guides/user-experience/consistent-cross-document-transitions.md+++ b/skills/modern-web-guidance/guides/user-experience/consistent-cross-document-transitions.md@@ -32,6 +32,13 @@ MANDATORY: Both the source and destination pages must include the `@view-transit@view-transition {navigation: auto;}++/* MANDATORY Copy-Paste Safety: Disable cross-document view transitions for users requesting reduced motion */+@media (prefers-reduced-motion: reduce) {+ @view-transition {+ navigation: none;+ }+}```### Step 2: Block Rendering Until Critical Scripts Execute@@ -200,6 +207,7 @@ window.addEventListener('pagereveal', async (event) => {- **DO** keep render-blocking scripts small and fast. The browser has a built-in timeout (around 4 seconds), after which the transition is skipped entirely with a `TimeoutError`.- **DO NOT** use `<link rel="expect">` to block on elements deep in the page that are not visible in the initial viewport. This delays the transition without visual benefit.- **DO NOT** assign the same `view-transition-name` to multiple elements on the same page. Duplicate names cause the entire transition to be skipped.+- **Assistive Technology Timing Impact**: Using `blocking="render"` delays visual updates and initial paint. While this prevents visual glitches for sighted users, it can cause processing latency or deferred initialization for screen readers and other assistive technologies that depend on rendered accessibility trees. Weigh the visual continuity benefits against the initial read latency for non-visual users, and ensure render-blocking scripts are minimal and extremely optimized.## Fallback Strategiesdiff --git a/skills/modern-web-guidance/guides/user-experience/content-based-styling.md b/skills/modern-web-guidance/guides/user-experience/content-based-styling.mdindex dfb0293..7bc561d 100644--- a/skills/modern-web-guidance/guides/user-experience/content-based-styling.md+++ b/skills/modern-web-guidance/guides/user-experience/content-based-styling.md@@ -51,6 +51,7 @@ To build a component that changes its layout based on its content:``````html+<!-- Assume an <h1> precedes these components in the document layout --><!-- A card WITH an image (will use row layout) --><article class="article-card"><img src="thumbnail.jpg" alt="Article thumbnail" />diff --git a/skills/modern-web-guidance/guides/user-experience/interactive-content-reveal.md b/skills/modern-web-guidance/guides/user-experience/interactive-content-reveal.mdindex 8d7008b..fad927a 100644--- a/skills/modern-web-guidance/guides/user-experience/interactive-content-reveal.md+++ b/skills/modern-web-guidance/guides/user-experience/interactive-content-reveal.md@@ -75,16 +75,16 @@ container.addEventListener('pointermove', (e) => {```### 4. Accessibility and Interaction-MANDATORY: Ensure the reveal effect does not interfere with content accessibility. Avoid using this effect for revealing essential content.+**MANDATORY Accessibility Guarantee:** This pattern relies on pointer interactions to reveal a visual spotlight. You MUST guarantee that all underlying content remains fully visible, legible, and independently keyboard-reachable by default in the underlying layout, using the spotlight layer purely as a non-essential visual enhancement for pointer users. Never use this effect to obscure or gate essential content from keyboard-only or assistive technology users.-* **Pointer Events:** If the reveal layer is an overlay, set `pointer-events: none` to allow users to interact with buttons or links underneath.-* **Non-Pointer Inputs:** Consider disabling the effect for users without a pointer using the `@media (pointer: none)` media query, especially if the revealed content is critical.-* **Reduced Motion:** Respect user preferences for reduced motion by disabling transitions or the effect entirely.+* **Pointer Events:** Set `pointer-events: none` on the mask overlay layer to allow standard click and touch interactions to pass through to controls underneath.+* **Reduced Motion Override:** Disable smooth transition interpolation for users requesting reduced motion.```css+/* MANDATORY Copy-Paste Safety: Disable transition scaling for motion-sensitive users */@media (prefers-reduced-motion: reduce) {.reveal-layer {- transition: none;+ transition: none !important;}}```diff --git a/skills/modern-web-guidance/guides/user-experience/interest-triggered-action-previews.md b/skills/modern-web-guidance/guides/user-experience/interest-triggered-action-previews.mdindex 074fdc3..db8fb7e 100644--- a/skills/modern-web-guidance/guides/user-experience/interest-triggered-action-previews.md+++ b/skills/modern-web-guidance/guides/user-experience/interest-triggered-action-previews.md@@ -25,6 +25,9 @@ interestingElement.addEventListener("loseinterest", event => {});```+> [!NOTE]+> **Don't announce interest-driven previews via a live region.** Interest can be triggered just by moving the pointer across the page or tabbing through nearby buttons, so apply/unapply announcements quickly become noise that can drown out content the user actually cares about. The preview itself is the affordance; users who can perceive it benefit directly, and those who can't will not benefit from a verbal echo of "Previewing effect: A". If you decide you genuinely need an announcement for a specific case, make sure to test it carefully with users.+Active interest sources and targets can be selected with CSS using the `:interest-source` and `:interest-target` pseudo-selectors respectively.```css@@ -48,7 +51,7 @@ Interest invokers has limited availability.Supported by: Chrome 142 (Oct 2025) and Edge 142 (Oct 2025).Unsupported in: Firefox and Safari.-Interest invokers must be conditionally polyfilled with the `interestfor` polyfill, available at https://github.com/mfreed7/interestfor or on NPM. Do prefer bundling the polyfill over using the CDN.+Interest invokers must be conditionally polyfilled using the `interestfor` polyfill package from NPM. Do prefer bundling the polyfill over using the CDN.```html<script type="module">diff --git a/skills/modern-web-guidance/guides/user-experience/interest-triggered-tooltips.md b/skills/modern-web-guidance/guides/user-experience/interest-triggered-tooltips.mdindex 9457825..09ebe5d 100644--- a/skills/modern-web-guidance/guides/user-experience/interest-triggered-tooltips.md+++ b/skills/modern-web-guidance/guides/user-experience/interest-triggered-tooltips.md@@ -26,7 +26,22 @@ A user expresses interest in the additional information by hovering or focusing<a interestfor="tooltip" href="">Tooltip trigger</a>```-The trigger must have a visual indicator to indicate that there is additional information available by interacting with the trigger.+The trigger must have a visual indicator to indicate that there is additional information available by interacting with the trigger.++### Accessibility built in to `interestfor`++`interestfor` handles the assistive-technology wiring for you, so you generally do not need to add ARIA attributes manually:++- 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").++### Accessibility Constraints (WCAG 1.4.13)++Even with `interestfor` handling the semantics above, your implementation MUST still satisfy WCAG 1.4.13 (Content on Hover or Focus):+- **Dismissible:** Users must be able to dismiss the tooltip without moving pointer hover or keyboard focus (e.g., by pressing the `Escape` key). The native `popover` attribute manages this binding automatically.+- **Hoverable:** The pointer must be able to move over the tooltip content itself without the tooltip disappearing. This allows users with magnification tools to read the tooltip text safely.+- **Persistent:** The tooltip must remain visible until the hover or focus trigger is removed, the user explicitly dismisses it, or its content is no longer valid.### Positioning the tooltip@@ -62,7 +77,7 @@ Interest invokers has limited availability.Supported by: Chrome 142 (Oct 2025) and Edge 142 (Oct 2025).Unsupported in: Firefox and Safari.-Interest invokers must be conditionally polyfilled with the `interestfor` polyfill, available at https://github.com/mfreed7/interestfor or on NPM. Do prefer bundling the polyfill over using the CDN.+Interest invokers must be conditionally polyfilled using the `interestfor` polyfill package from NPM. Do prefer bundling the polyfill over using the CDN.```html<script type="module">diff --git a/skills/modern-web-guidance/guides/user-experience/navigation-drawer.md b/skills/modern-web-guidance/guides/user-experience/navigation-drawer.mdindex 5eb691b..ccbebe3 100644--- a/skills/modern-web-guidance/guides/user-experience/navigation-drawer.md+++ b/skills/modern-web-guidance/guides/user-experience/navigation-drawer.md@@ -39,10 +39,11 @@ The drawer is a single popover containing a horizontal scroller, which contains<!-- aria-controls links the trigger to the drawer; aria-expandedreflects the current state for assistive tech. --><button id="drawer-open"- aria-label="Open menu"+ aria-label="Menu"aria-expanded="false"aria-controls="drawer">- <!-- menu icon SVG -->+ <!-- MANDATORY: Inline decorative SVGs MUST define aria-hidden="true" -->+ <svg aria-hidden="true" viewBox="0 0 24 24">...</svg></button></header><!-- Page content. -->@@ -286,6 +287,9 @@ document.addEventListener('keydown', (event) => {### Fallback strategies+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 drawer's core mechanics — scroll snap, `IntersectionObserver`, and `inert` — are all Baseline Widely available and required for the component to function. The popover API, the scroll-driven animation that fades the backdrop, and `scroll-initial-target` are progressive enhancements with simple fallbacks that can be easily implemented if wide browser support is required.#### Backdrop fade fallback (no `animation-timeline` support):diff --git a/skills/modern-web-guidance/guides/user-experience/persistent-app-tours.md b/skills/modern-web-guidance/guides/user-experience/persistent-app-tours.mdindex c20af12..7ae6bb2 100644--- a/skills/modern-web-guidance/guides/user-experience/persistent-app-tours.md+++ b/skills/modern-web-guidance/guides/user-experience/persistent-app-tours.md@@ -8,8 +8,10 @@ Onboarding tours require overlays that persist while users interact with the hig```html<div id="feature-target">Highlight this feature</div>-<div id="tour-step" popover="manual">- <h3>Step 1</h3>+<!-- MANDATORY: Enforce overlay dialog semantics and accessible name bindings -->+<div id="tour-step" popover="manual" role="dialog" aria-labelledby="tour-title">+ <!-- Assume an <h1> precedes this element in the full document outline -->+ <h2 id="tour-title">Step 1</h2><p>Learn how to use this feature.</p><button popovertarget="tour-step" popovertargetaction="hide">Got it</button></div>@@ -36,19 +38,22 @@ Onboarding tours require overlays that persist while users interact with the hig#### JavaScript```javascript-document.getElementById('tour-step').showPopover();+const tourStep = document.getElementById('tour-step');+tourStep.showPopover();+// MANDATORY: Programmatically route focus into the non-modal popover so keyboard/assistive technology users immediately perceive the new context+tourStep.querySelector('button').focus();```### Implementation Guidelines* **MANDATORY:** Use `popover="manual"` to prevent the tour step from closing accidentally during user interaction.+* **MANDATORY:** Mark the container with `role="dialog"` and link its heading via `aria-labelledby`.+* **MANDATORY:** Shift programmatic focus inside the popover immediately after opening to prevent focus abandonment.* **DO** use CSS Anchor Positioning to tether the tour step to the specific feature being explained.* **DO** provide an explicit "Close" or "Next" button within the popover that uses `popovertargetaction="hide"`.### Fallback strategies-#### 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).diff --git a/skills/modern-web-guidance/guides/user-experience/position-aware-tooltips.md b/skills/modern-web-guidance/guides/user-experience/position-aware-tooltips.mdindex 80a08d8..99790b8 100644--- a/skills/modern-web-guidance/guides/user-experience/position-aware-tooltips.md+++ b/skills/modern-web-guidance/guides/user-experience/position-aware-tooltips.md@@ -15,7 +15,7 @@ By setting `container-type: anchored` on your positioned element, you turn it inUse the Popover API to create a tooltip. This creates an implicit anchor connection that can be used for positioning.```html-<button popovertarget="tooltip" id="anchor">anchor</button>+<button popovertarget="tooltip" id="anchor" aria-describedby="tooltip">anchor</button><div id="tooltip" popover role="tooltip"></div>```diff --git a/skills/modern-web-guidance/guides/user-experience/resilient-context-menus-and-nested-dropdowns.md b/skills/modern-web-guidance/guides/user-experience/resilient-context-menus-and-nested-dropdowns.mdindex 80bcfba..df36255 100644--- a/skills/modern-web-guidance/guides/user-experience/resilient-context-menus-and-nested-dropdowns.md+++ b/skills/modern-web-guidance/guides/user-experience/resilient-context-menus-and-nested-dropdowns.md@@ -1,31 +1,36 @@-A dropdown menu is a useful pattern for users to access additional functionality while taking up minimal space. This overlay pattern comes with layout complexity, as the menu must remain tethered to a trigger element while adapting to the viewport constraints. Traditionally, this required complex JavaScript libraries (like Popper.js or Floating UI) to calculate positions and handle collisions.+A revealed action panel or popover button group is a useful pattern for users to access additional functionality while taking up minimal space. This overlay pattern comes with layout complexity, as the panel must remain tethered to a trigger element while adapting to viewport constraints. Traditionally, this required complex JavaScript libraries (like Popper.js or Floating UI) to calculate positions and handle collisions.-CSS Anchor Positioning provides a declarative, performance-optimized way to handle these relationships entirely in CSS, allowing browsers to manage the positioning and overflow logic.+CSS Anchor Positioning provides a declarative, performance-optimized way to handle these relationships entirely in CSS, allowing browsers to manage the positioning and overflow logic natively.-### 1. Define the Button and Menu Relationship+> [!NOTE]+> This guide demonstrates anchor-positioning and popover mechanics — it does not prescribe a specific accessible UI pattern. The trigger and panel below are shown as a plain **button-revealing-a-button-group**. If you need a true ARIA menu (`role="menu"` with arrow-key navigation), a combobox, a disclosure widget, or any other named pattern, layer that pattern's full semantics and keyboard contract on top of the positioning techniques shown here.-The first step is to create a button that opens a dropdown menu, using the Popover API.+### 1. Define the Button and Panel Relationship++The first step is to create a trigger button that opens the overlay container using the Popover API.++**MANDATORY Accessibility Distinction:** This pattern explicitly models a **button group revealed inside a popover** rather than a true ARIA menu. Do not apply `role="menu"` or `role="menuitem"` unless you fully implement the corresponding keyboard navigation contract (such as handling spatial arrow-key navigation between items). For the same reason, do not add `aria-haspopup` to the trigger — its value (`menu`, `listbox`, `tree`, `grid`, or the legacy `true`) is a promise that the target exposes a matching role, which this pattern does not.```html-<button popovertarget="dropdown-menu">- Open+<button popovertarget="action-panel">+ Open Actions</button>-<!-- Use the Popover API (`popover="auto"`) for the overlay to ensure it is placed in the top-layer and handled accessibly by the browser. -->-<div id="dropdown-menu" popover="auto">- <button class="menu-item" type="button">Edit</button>+<!-- Use the Popover API (`popover="auto"`) for the overlay to ensure it is placed in the top layer and handled accessibly by the browser. -->+<div id="action-panel" popover="auto" class="panel">+ <button class="action-item" type="button">Edit</button></div>```-This creates an *implicit* anchor association between the button and the menu, so that the menu can be positioned relative to the button.+This creates an *implicit* anchor association between the button and the panel, so that the panel can be positioned relative to the button.### 2. Positioning with `position-area`Instead of manual `top`/`left` offsets, use `position-area` to place the target on a 3x3 grid relative to the anchor.```css-.menu {+.panel {/*- Position the menu below the anchor (block-end),+ Position the panel below the anchor (block-end),aligned to the start of the anchor and spanning to its end (span-inline-end).*/position-area: block-end span-inline-end;@@ -41,19 +46,19 @@ Prefer logical keywords (`span-inline-end`, `block-start`) over physical ones (`### 3. Implement Edge-Resilience (Fallbacks)-To prevent the menu from being cut off at the edge of the screen, define "try tactics" that the browser should attempt if the default position overflows.+To prevent the panel from being cut off at the edge of the screen, define "try tactics" that the browser should attempt if the default position overflows.```css-.menu {+.panel {/*- If the menu overflows the bottom, flip it to the top (flip-block).+ If the panel overflows the bottom, flip it to the top (flip-block).If it overflows the inline edges, flip it horizontally (flip-inline).*/position-try-fallbacks: flip-block, flip-inline;}```-### Fallback strategies+## Fallback strategiesBaseline 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).@@ -84,7 +89,7 @@ For some use cases, you may be able to use the `@oddbird/css-anchor-positioning```````css-.menu{+.panel {/* Mandatory: use explicit anchor name */position-anchor: --kebab-anchor;/* Mandatory: use insets rather that position-area for positioning */diff --git a/skills/modern-web-guidance/guides/user-experience/same-document-transitions.md b/skills/modern-web-guidance/guides/user-experience/same-document-transitions.mdindex c28d61e..0730891 100644--- a/skills/modern-web-guidance/guides/user-experience/same-document-transitions.md+++ b/skills/modern-web-guidance/guides/user-experience/same-document-transitions.md@@ -75,24 +75,33 @@ function goFromListToDetail(e){// Trigger the transition, checking for supportif (!document.startViewTransition) {document.body.classList.add("detail");+ // MANDATORY Accessibility Routing: Route focus to the newly revealed heading to announce context and preserve logical tab flow+ document.getElementById("detail-heading")?.focus();return; // MANDATORY: End function execution if view transitions are not supported.}const transition = document.startViewTransition(() => {document.body.classList.add("detail");});+ // MANDATORY Accessibility Routing: Route focus after the view transition resolves+ transition.finished.finally(() => {+ document.getElementById("detail-heading")?.focus();+ });}// Function called when navigating from detail back to list viewfunction goFromDetailToList() {if (!document.startViewTransition) {document.body.classList.remove("detail");+ document.getElementById("list-heading")?.focus();return;}const transition = document.startViewTransition(() => {document.body.classList.remove("detail");});- // Clean up the list view+ // Clean up the list view and route focustransition.finished.finally(() => {+ // Route focus back to list view+ document.getElementById("list-heading")?.focus();// Remove selected classList to remove view-transition-namesdocument.querySelectorAll(".selected").forEach((element) => {@@ -137,6 +146,7 @@ The pseudo-elements are snapshots of the live elements, so you can also use `obj- **DO** remove temporary `view-transition-name` values after the transition finishes to avoid side effects on future transitions.- **DO NOT** transition elements with active animations. View transitions operate on snapshots, so any animations will appear to be paused during the view transition.- **DO** respect user preferences for reduced motion using the `prefers-reduced-motion` media query.+- **MANDATORY Accessibility Routing**: View transitions morph page layouts dynamically but do not manage programmatic focus. If focus remains on an element that is hidden or removed during the transition, focus is abandoned, leaving keyboard and assistive technology users without context. Shift focus programmatically to an updated page heading or view container (using `tabindex="-1"`) immediately after the DOM updates or when the view transition's `finished` promise resolves.```css@media (prefers-reduced-motion: reduce) {diff --git a/skills/modern-web-guidance/guides/user-experience/scroll-progress-indicator.md b/skills/modern-web-guidance/guides/user-experience/scroll-progress-indicator.mdindex f1f9d3c..fa2f922 100644--- a/skills/modern-web-guidance/guides/user-experience/scroll-progress-indicator.md+++ b/skills/modern-web-guidance/guides/user-experience/scroll-progress-indicator.md@@ -45,7 +45,8 @@ Because of its location in the DOM, the `scroll()` function will track its neare```html<body>- <div id="progress"></div>+ <!-- MANDATORY: Purely decorative visual scroll progress bars MUST set aria-hidden="true" to remove the empty element from the assistive technology reading tree -->+ <div id="progress" aria-hidden="true"></div></body>```@@ -84,6 +85,7 @@ When using scroll-driven animations, it's important to follow a few best practic- **DO** include feature detection: Not all browsers support scroll-driven animations. Use `@supports (animation-timeline: scroll())` to check for support and provide a fallback for browsers that don't support it.- **DO NOT** use the `scroll-timeline-polyfill` package for the fallback strategy as it is not feature complete and has a lot of known issues.- If the animation is only considered to be decorative, opt for Progressive Enhancement and **DO NOT** provide a fallback.+- **DO** remove purely decorative elements from assistive technology reading flows: Apply `aria-hidden="true"` to purely visual scroll indicators to ensure screen readers do not encounter empty, unnamed nodes.- **DO** respect user preferences: Some users prefer to have less motion on the web. Use the `prefers-reduced-motion` media query to disable or reduce your animations for these users.- **DO** try to animate only performant CSS properties: For the smoothest animations, stick to animating properties that can be handled by the browser's compositor thread, such as `transform` and `opacity`. Animating other properties like `width` or `height` can lead to performance issues.- **DO** use the correct declaration order: When using the `animation` shorthand property, declare `animation-timeline` *after* it to prevent the shorthand from resetting the timeline.@@ -100,11 +102,11 @@ When using the `scroll-timeline` property to create a scroll-driven animation:- **OPTIONAL** be explicit about the axis to track: When not targeting the default `block` axis (such as in a horizontal scroller), be explicit about which axis to track with `scroll-timeline-axis`.- **DO** make sure the scope of the lookup works: When the element that is declaring the `scroll-timeline` is not a flat tree ancestor of the animated element, hoist up the visibility of the `scroll-timeline`’s name by using `timeline-scope` on a shared ancestor.-## Browser support and fallback strategies+## Fallback strategiesScroll-driven animations has limited availability.Supported by: Chrome 115 (Jul 2023), Edge 115 (Jul 2023), and Safari 26 (Sep 2025).-Unsupported in: Firefox.. Therefore, a fallback strategy is typically required.+Unsupported in: Firefox.For browsers that do not support scroll-driven animations, you can use a fallback to recreate the visual effects. The fallbacks are typically built with either a scroll listener (for ScrollTimeline effects) or the IntersectionObserver API (for ViewTimeline effects).diff --git a/skills/modern-web-guidance/guides/user-experience/scroll-snap-state-sync.md b/skills/modern-web-guidance/guides/user-experience/scroll-snap-state-sync.mdindex 8ab520e..a1f30f6 100644--- a/skills/modern-web-guidance/guides/user-experience/scroll-snap-state-sync.md+++ b/skills/modern-web-guidance/guides/user-experience/scroll-snap-state-sync.md@@ -21,6 +21,16 @@ h2 {### 2. Listen for Snap ChangesUse the `scrollsnapchange` event on the scroll container to react when the user finishes scrolling and the browser snaps to a new element. In our TOC demo, we use this to highlight the active link in the sidebar.+```html+<!-- MANDATORY: Wrap table of contents links inside a proper navigation landmark -->+<nav aria-label="Table of contents">+ <ul>+ <li><a href="#section-1" aria-current="location">Section 1</a></li>+ <li><a href="#section-2">Section 2</a></li>+ </ul>+</nav>+```+```javascriptconst main = document.getElementById('main');const links = document.querySelectorAll('nav a');diff --git a/skills/modern-web-guidance/guides/user-experience/scrollytelling.md b/skills/modern-web-guidance/guides/user-experience/scrollytelling.mdindex c344602..dfc6ae2 100644--- a/skills/modern-web-guidance/guides/user-experience/scrollytelling.md+++ b/skills/modern-web-guidance/guides/user-experience/scrollytelling.md@@ -87,6 +87,15 @@ html {section:nth-child(4){ animation-timeline: --tl-4; }section:nth-child(5){ animation-timeline: --tl-5; }}++/* MANDATORY Copy-Paste Safety: Disable continuous storytelling motion for sensitive users */+@media (prefers-reduced-motion: reduce) {+ #animated section {+ animation: none !important;+ opacity: 1 !important;+ transform: none !important;+ }+}```## Best Practices@@ -107,11 +116,11 @@ When using the `view-timeline` property to create a scroll-driven animation:- **OPTIONAL** be explicit about the axis to track: When not targeting the default `block` axis (such as in a horizontal scroller), be explicit about which axis to track with `view-timeline-axis`.- **DO** make sure the scope of the lookup works: When the element that is declaring the `view-timeline` is not a flat tree ancestor of the animated element, hoist up the visibility of the `view-timeline`’s name by using `timeline-scope` on a shared ancestor.-## Browser support and fallback strategies+## Fallback strategiesScroll-driven animations has limited availability.Supported by: Chrome 115 (Jul 2023), Edge 115 (Jul 2023), and Safari 26 (Sep 2025).-Unsupported in: Firefox.. Therefore, a fallback strategy is typically required.+Unsupported in: Firefox.For browsers that do not support scroll-driven animations, you can use a fallback to recreate the visual effects. The fallbacks are typically built with either a scroll listener (for ScrollTimeline effects) or the IntersectionObserver API (for ViewTimeline effects).@@ -158,6 +167,15 @@ And the accompanying CSS:transform: scale(0.5) rotateY(-180deg);backface-visibility: hidden;}++/* MANDATORY Copy-Paste Safety: Ensure content remains fully visible and legible for assistive technologies or users with motion sensitivities */+@media (prefers-reduced-motion: reduce) {+ #animated section {+ opacity: 1 !important;+ transform: none !important;+ translate: 0 0 !important;+ }+}```This fallback provides a more accurate, scroll-driven animation for browsers that do not support the native CSS feature, ensuring a more consistent experience for all users. By using a series of thresholds for the `IntersectionObserver`, we can track the scroll position with more precision and create a smoother animation.\ No newline at end of filediff --git a/skills/modern-web-guidance/guides/user-experience/search-hidden-content.md b/skills/modern-web-guidance/guides/user-experience/search-hidden-content.mdindex 9640fc1..212685c 100644--- a/skills/modern-web-guidance/guides/user-experience/search-hidden-content.md+++ b/skills/modern-web-guidance/guides/user-experience/search-hidden-content.md@@ -35,26 +35,26 @@ If you need to use `hidden="until-found"` instead, follow these instructions:</details>```-#### Mutually exclusive content (e.g. tabs)+#### Mutually exclusive disclosures-When handling mutually exclusive regions, like tabs, use the native HTML `<details>` element with a shared `name` attribute.+When handling mutually exclusive content regions, like an exclusive accordion, use the native HTML `<details>` element with a shared `name` attribute.```html-<div class="tab-container">- <!-- The name attribute creates an exclusive accordion/tab group -->- <details class="tab" name="my-tabs">- <summary>Tab 1 (closed)</summary>- <p>Tab 1 content</p>+<div class="accordion-group">+ <!-- The name attribute creates an exclusive disclosure group -->+ <details class="disclosure" name="my-accordion">+ <summary>Section 1</summary>+ <p>Section 1 content</p></details>- <details class="tab" name="my-tabs" open>- <summary>Tab 2 (open)</summary>- <p>Tab 2 content</p>+ <details class="disclosure" name="my-accordion" open>+ <summary>Section 2</summary>+ <p>Section 2 content</p></details>- <details class="tab" name="my-tabs">- <summary>Tab 3 (closed)</summary>- <p>Tab 3 content</p>+ <details class="disclosure" name="my-accordion">+ <summary>Section 3</summary>+ <p>Section 3 content</p></details></div>```@@ -68,33 +68,40 @@ When handling mutually exclusive regions, like tabs, use the native HTML `<detai</div>```-#### Mutually exclusive content (e.g. tabs)+#### Custom mutually exclusive disclosures-When handling mutually exclusive regions, like tabs, ensure only the matched tab becomes visible. Since the `beforematch` event bubbles, you can listen on a parent container to manage state before the browser reveals the matched content.+When handling custom mutually exclusive regions controlled by external buttons, ensure only the matched panel remains visible. In the `beforematch` event handler, you MUST synchronize related ARIA states such as setting `aria-expanded="true"` on the controlling button.```html-<div class="tab-container">- <div class="tab">- <p>Tab 1 content (visible)</p>+<div class="custom-accordion">+ <div class="controls">+ <button aria-expanded="true" aria-controls="panel-1" id="btn-1">Section 1</button>+ <button aria-expanded="false" aria-controls="panel-2" id="btn-2">Section 2</button></div>- <div class="tab" hidden="until-found">- <p>Tab 2 content (hidden)</p>+ <div id="panel-1" class="panel">+ <p>Section 1 content (visible)</p></div>- <div class="tab" hidden="until-found">- <p>Tab 3 content (hidden)</p>+ <div id="panel-2" class="panel" hidden="until-found">+ <p>Section 2 content (hidden)</p></div></div>``````javascript-const tabContainer = document.querySelector('.tab-container');--tabContainer.addEventListener('beforematch', () => {- // Hide all tabs before the browser reveals the matched tab- tabContainer.querySelectorAll('.tab').forEach((tab) => {- tab.hidden = 'until-found';+const accordion = document.querySelector('.custom-accordion');++accordion.addEventListener('beforematch', (e) => {+ // Hide all panels and synchronize button states before the browser reveals the matched panel+ accordion.querySelectorAll('.panel').forEach((panel) => {+ if (panel !== e.target) {+ panel.hidden = 'until-found';+ }+ });+ accordion.querySelectorAll('button').forEach((btn) => {+ const controls = btn.getAttribute('aria-controls');+ btn.setAttribute('aria-expanded', controls === e.target.id ? 'true' : 'false');});});```@@ -126,4 +133,4 @@ if (!('onbeforematch' in HTMLElement.prototype)) {}```-For mutually exclusive UI paradigms (like tabs where content shares the same visual region), the fallback should extract and display all content linearly below the main interactive area, using URL anchor fragments to allow users to navigate directly to the respective sections.+For mutually exclusive UI paradigms (like custom exclusive panels where content shares the same visual region), the fallback should extract and display all content linearly below the main interactive area, using URL anchor fragments to allow users to navigate directly to the respective sections.