OnlineNexusAccess accessibility home Free scan

WooCommerce accessibility fixes you can make in a child theme

Many WooCommerce accessibility problems come from the theme: invisible focus outlines, pale text, headings at the wrong level. It is tempting to edit the theme files directly, but those edits can be lost the next time the theme updates. A child theme keeps your fixes separate and safe. This guide sets one up and walks through the most common fixes. It assumes a classic (PHP) theme such as Storefront; block themes are mostly customised in the Site Editor instead.

Why a child theme

The WordPress Theme Handbook describes child themes as extensions of a parent theme that let you modify an existing theme without directly editing its code, so the parent can be updated without losing your modifications (Child Themes (WordPress Theme Handbook)). Always test on a staging copy of your site first if your host offers one, and keep a backup.

Step 1: Create the child theme

Create a folder in wp-content/themes/, for example storefront-child, with a style.css file. The Template line must exactly match the parent theme's folder name (Child Themes (WordPress Theme Handbook)).

wp-content/themes/storefront-child/style.css
/*
 * Theme Name: Storefront Child
 * Template: storefront
 */

Then activate it under Appearance > Themes. Your store should look exactly the same. If it doesn't, check the Template line.

Step 2: Load your stylesheet

Add a functions.php to the child theme and load its stylesheet with wp_enqueue_style() (wp_enqueue_style() (WordPress developer reference)). Whether you also need to load the parent's stylesheet depends on the parent theme; the handbook explains both cases (Child Themes (WordPress Theme Handbook)).

wp-content/themes/storefront-child/functions.php
<?php
add_action( 'wp_enqueue_scripts', function () {
    wp_enqueue_style(
        'storefront-child-style',
        get_stylesheet_uri(),
        array(),
        wp_get_theme()->get( 'Version' )
    );
}, 20 );

Step 3: Focus and contrast CSS

Two of the most common problems we see can be fixed with CSS alone. A visible focus indicator helps keyboard users see where they are (Understanding Success Criterion 2.4.7: Focus Visible (W3C WAI)); our guide to missing focus outlines explains the details. Low contrast was the second most common problem in our scan of 10 stores. Check your colors with the contrast checker first, then override them.

Add to the child theme's style.css
/* Visible focus for keyboard users, without showing it on mouse click */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.button:focus-visible {
  outline: 3px solid #1a4fd6;
  outline-offset: 2px;
}

/* Example: darken pale sale prices and grey text that fail 4.5:1 */
.woocommerce ul.products li.product .price,
.woocommerce div.product p.price del {
  color: #4a4a4a;
}

Replace the selectors and colors with the ones your theme actually uses; your browser's developer tools show which rule sets each color.

Step 4: Fix heading levels with hooks

WooCommerce prints product titles in shop grids as <h2> through woocommerce_template_loop_product_title(), hooked to woocommerce_shop_loop_item_title (includes/wc-template-functions.php (WooCommerce, GitHub); includes/wc-template-hooks.php (WooCommerce, GitHub)). If a grid sits under an H2 section title on your homepage, H3 product titles keep the outline tidy. You can swap the function from the child theme without touching template files; the code is in our guide to headings that skip levels. Widget titles come from the theme's register_sidebar() settings, where before_title defaults to an H2 (register_sidebar() (WordPress developer reference)).

Step 5: Override a template only when you have to

WooCommerce lets a theme override its templates: copy the file from wp-content/plugins/woocommerce/templates/ into a woocommerce folder in your child theme, keeping the same folder structure but without the templates part (Template structure & overriding templates via a theme (WooCommerce developer docs)). For example, to change the variation drop-downs you would copy single-product/add-to-cart/variable.php to storefront-child/woocommerce/single-product/add-to-cart/variable.php (single-product/add-to-cart/variable.php template (WooCommerce, GitHub)).

Use this sparingly. The default templates already include useful accessibility features: the variation template labels each drop-down and includes a screen-reader-only live region (single-product/add-to-cart/variable.php template (WooCommerce, GitHub)), and the mini-cart labels each remove link with the product name (cart/mini-cart.php template (WooCommerce, GitHub)). Every override is a copy you have to maintain. Prefer hooks and CSS where they can do the job.

Step 6: Check for outdated templates after updates

When WooCommerce updates a template you have overridden, your copy can fall behind, and you can miss fixes, including accessibility improvements. WooCommerce's docs explain how to find them: go to WooCommerce > Status > System Status and scroll to the list of templates overridden by your theme or child theme, which warns when they need updating (How to fix outdated WooCommerce templates (WooCommerce developer docs)). Re-copy the new default and re-apply your change.

Check your own store in a minute or two. Our free scanner opens your homepage, a collection page, a product page and your cart in a real browser and lists the problems it can detect automatically, in plain English.

Run the free scan

Common questions

Can I use a plugin for custom CSS instead?

Yes, for CSS-only fixes. The Customizer's Additional CSS panel or a code snippets plugin also survives theme updates. A child theme is better when you need PHP hooks or template overrides.

Will a child theme slow my site down?

One small extra stylesheet has little effect. Keep it lean and avoid copying the whole parent stylesheet.

What should I fix first?

Run the WooCommerce accessibility checker and work through the WooCommerce checklist, starting with anything that blocks buying: the menu, product options, cart and checkout.

Technical fixes, not legal advice. This guide explains website accessibility from a technical point of view. We are not a law firm, and nothing here is legal advice. No scan, fix or guide can guarantee legal compliance, the outcome of any demand letter or lawsuit, or protection from future claims. If you have received a legal claim, please consult a qualified attorney about it.

Sources