Fix aria-valid-attr-value in Shopify Liquid
Shopify Liquid themes often break aria-valid-attr-value when an ID interpolated with {{ block.id }} or {{ section.id }} differs slightly between the trigger's aria-controls and the panel's id, or when a Liquid boolean outputs blank (aria-expanded='') instead of 'true' / 'false'.
Before and after
{%- comment -%} sections/collapsible-content.liquid (Broken: empty Liquid boolean & wrong ID) {%- endcomment -%}
<button
type="button"
aria-expanded="{{ block.settings.open_by_default }}"
aria-controls="AccordionContent-{{ block.id }}"
>
{{ block.settings.heading | escape }}
</button>
<div id="Accordion-{{ block.id }}">
{{ block.settings.row_content }}
</div>{%- comment -%} sections/collapsible-content.liquid (Fixed: guaranteed true/false & matching IDREF) {%- endcomment -%}
{%- assign is_open = block.settings.open_by_default | default: false -%}
<button
type="button"
aria-expanded="{% if is_open %}true{% else %}false{% endif %}"
aria-controls="AccordionContent-{{ section.id }}-{{ block.id }}"
>
{{ block.settings.heading | escape }}
</button>
<div
id="AccordionContent-{{ section.id }}-{{ block.id }}"
{% unless is_open %}hidden{% endunless %}
>
{{ block.settings.row_content }}
</div>Fixed vs. broken example
Never interpolate unvalidated booleans, undefined IDs, or custom strings like 'open'/'closed' into ARIA attributes; only render aria-controls when the controlled ID exists in the DOM.
Playwright + axe-core check
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
test("Shopify collapsible sections & drawers pass aria-valid-attr-value", async ({ page }) => {
await page.goto("/products/cobalt-ceramic-mug");
const results = await new AxeBuilder({ page })
.withRules(["aria-valid-attr-value"])
.analyze();
expect(results.violations).toEqual([]);
});Template deduplication tip
A mismatched aria-controls='CartDrawer' vs id='cart-drawer' in sections/header.liquid or sections/collapsible-content.liquid creates a site-wide cluster across every storefront route. Fix the Liquid ID expression once to clear all URLs.
What NVDA and VoiceOver announce
Invalid ARIA tokens (like aria-expanded='open'), broken IDREFs (aria-controls pointing to a nonexistent or unmounted ID), or mistyped booleans cause browsers and screen readers to silently drop interactive state announcements.
NVDA (Windows)
"Shipping & Returns FAQ, button" (collapsed/expanded state omitted due to invalid token)
"Shipping & Returns FAQ, button, expanded"
VoiceOver (macOS / iOS)
"Shipping & Returns FAQ, button" (state not exposed)
"Shipping & Returns FAQ, expanded, button"
Common questions
Why does {{ block.settings.open_by_default }} sometimes output an empty aria-expanded=''?
Can Liquid whitespace inside aria-labelledby break axe-core?
What causes aria-hidden='1' or aria-disabled='disabled' in older Shopify themes?
Test a URL for aria-valid-attr-value
Enter any public URL for a free WCAG 2.2 AA check—no account or credit card required.
Managing Shopify Liquid client sites? Monitor 15 sites on one flat plan with white-label portals and branded executive PDFs—$1,140/yr ($95/mo billed annually, 24-month rate lock + onboarding) for Founding 10 agencies.