A form field without a label is a box with no question. Sighted shoppers can often guess from the placeholder text or the layout, but screen reader users may hear only "edit text", and placeholder text disappears as soon as anyone starts typing. Newsletter sign-ups, search boxes and quantity fields are the usual culprits on small stores. This guide shows how to fix them in Shopify and WooCommerce.
What counts as a label
WCAG success criterion 3.3.2 asks for labels or instructions when content requires user input (Understanding Success Criterion 3.3.2: Labels or Instructions (W3C WAI)), and 4.1.2 requires that each form control has a name software can read (Understanding Success Criterion 4.1.2: Name, Role, Value (W3C WAI)). The W3C forms tutorial recommends a visible <label> element tied to the field with matching for and id attributes as the most reliable approach (Labeling Controls (W3C WAI Forms Tutorial)).
These are not reliable labels on their own:
- Placeholder text ("Enter your email"). It vanishes while typing, is often low-contrast, and is not consistently treated as a label.
- A
titletooltip. Automated tools flag this as "Form fields labelled only by a hover tooltip" (label-title-only). In our 10-store test sample this showed up on 2 stores, affecting 18 fields, including WooCommerce quantity boxes labelled only by a "Qty" tooltip. - Nearby text that isn't connected. A heading saying "Join our newsletter" above a field looks like a label but isn't one unless the code links them.
Shopify: the newsletter sign-up
Shopify's form tag with the 'customer' type creates the newsletter form (form tag (Shopify Liquid reference)). Many themes hide the label and rely on the placeholder. A labelled version looks like this:
{%- form 'customer', id: 'NewsletterForm-{{ section.id }}' -%}
<input type="hidden" name="contact[tags]" value="newsletter">
<label for="NewsletterEmail-{{ section.id }}">Email address</label>
<input
id="NewsletterEmail-{{ section.id }}"
type="email"
name="contact[email]"
autocomplete="email"
autocapitalize="off"
required
{% if form.errors %}aria-invalid="true" aria-describedby="NewsletterError-{{ section.id }}"{% endif %}
>
<button type="submit">Subscribe</button>
{%- if form.errors -%}
<p id="NewsletterError-{{ section.id }}">
{{ form.errors.translated_fields.email | capitalize }} {{ form.errors.messages.email }}
</p>
{%- endif -%}
{%- if form.posted_successfully? -%}
<p role="status">Thanks for subscribing.</p>
{%- endif -%}
{%- endform -%}Things to notice: the id includes section.id so it stays unique if the section appears twice; autocomplete="email" lets browsers and password managers fill the field; and the error message is connected to the field with aria-describedby, so it's read out when the field is focused.
If your design has no room for a visible label, the label can be visually hidden with the theme's visually-hidden class. A visible label is better for everyone, including people with memory or attention difficulties, but a hidden label is far better than none.
Shopify: the search box
<form action="{{ routes.search_url }}" method="get" role="search">
<label for="SiteSearch" class="visually-hidden">Search the store</label>
<input id="SiteSearch" type="search" name="q"
value="{{ search.terms | escape }}"
placeholder="Search products">
<input type="hidden" name="options[prefix]" value="last">
<button type="submit">
<svg aria-hidden="true" focusable="false" class="icon icon-search">...</svg>
<span class="visually-hidden">Search</span>
</button>
</form>The submit button is an icon, so it also needs a text name; see our guide to icon buttons.
Shopify: the quantity selector
Quantity fields often sit between plus and minus buttons with the label hidden or missing. Give the field a label and the buttons a name that includes the product:
<label for="Quantity-{{ section.id }}">Quantity</label>
<div class="quantity">
<button type="button" name="minus">
<span class="visually-hidden">Decrease quantity for {{ product.title | escape }}</span>
<svg aria-hidden="true" focusable="false">...</svg>
</button>
<input id="Quantity-{{ section.id }}" type="number" name="quantity"
min="1" value="1" inputmode="numeric">
<button type="button" name="plus">
<span class="visually-hidden">Increase quantity for {{ product.title | escape }}</span>
<svg aria-hidden="true" focusable="false">...</svg>
</button>
</div>WooCommerce: quantity fields
WooCommerce's default quantity template already includes a screen-reader label, but some themes override global/quantity-input.php and drop it, or replace it with a tooltip. Check whether your theme has its own copy in your-theme/woocommerce/global/quantity-input.php. If it does, make sure the field has a real label. A simplified fragment:
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>">
<?php echo esc_html( $label ); ?>
</label>
<input
type="number"
id="<?php echo esc_attr( $input_id ); ?>"
class="input-text qty text"
name="<?php echo esc_attr( $input_name ); ?>"
value="<?php echo esc_attr( $input_value ); ?>"
min="<?php echo esc_attr( $min_value ); ?>"
step="<?php echo esc_attr( $step ); ?>"
inputmode="<?php echo esc_attr( $inputmode ); ?>"
autocomplete="off" />Compare your theme's copy with the current template in the WooCommerce plugin (woocommerce/templates/global/quantity-input.php) rather than pasting this fragment over it: templates change between versions, and WooCommerce shows outdated template overrides under WooCommerce > Status. Always edit a copy in a child theme (Child Themes (WordPress Theme Handbook)).
WooCommerce: custom fields you add
If you add a field to a product page or checkout with code, WooCommerce's woocommerce_form_field() function prints a proper <label> for you when you pass a label:
<?php
add_action( 'woocommerce_before_add_to_cart_button', function () {
woocommerce_form_field( 'gift_message', array(
'type' => 'textarea',
'label' => __( 'Gift message (optional)', 'your-child-theme' ),
'description' => __( 'Up to 200 characters. Printed on the packing slip.', 'your-child-theme' ),
'maxlength' => 200,
'required' => false,
) );
} );Don't pass an empty label and rely on placeholder instead. If a field is required, say so in the label text, not only with a red asterisk or colour.
WooCommerce: search and newsletter plugins
The WooCommerce product search widget and block include a label for the search field. Problems usually come from third-party newsletter or pop-up plugins. Look for a setting called "show label" or "field label" and turn it on. If there isn't one, contact the plugin developer; if they won't fix it, consider an alternative plugin. Our scan's results list the exact field so you can tell which plugin produced it.
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.
Error messages that help
Labels are half the job. When something goes wrong, the message should say what went wrong and how to fix it, in text, next to the field: "Enter an email address in the format name@example.com", not just a red border. Connect the message to the field with aria-describedby, as in the newsletter example, and set aria-invalid="true" on the field while the error is showing.
How to check your work
- Click on the label text. If the cursor moves into the field, the label is connected.
- Inspect the field in your browser's developer tools: the Accessibility pane should show the label as the field's name.
- Run the free scan again and check that
labelandlabel-title-onlyresults are gone. - Tab through the form with only the keyboard and submit it once with an error, to hear or see how errors are reported (see the keyboard test).
Common questions
Is a placeholder enough as a label?
No. Placeholder text disappears as soon as someone starts typing, it is often low contrast, and some assistive technology does not treat it as the field's name. Keep the placeholder as a hint if you like, but give every field a real label: a visible <label>, or at least an aria-label when the design has no room for visible text, such as a single search box with a clear search button next to it.
Can a label be visually hidden?
Yes. Many themes use a visually-hidden or screen-reader-text class that hides text on screen but keeps it available to screen readers. That is fine for a search box or a newsletter field whose purpose is obvious from the design. For checkout, account and contact forms, visible labels are better for everyone, including people who use speech recognition and say the label they can see.
Do checkboxes and radio buttons need labels too?
Yes. Each checkbox or radio button needs its own label, such as "Subscribe to emails" or a variant name. A group of radio buttons, like sizes or shipping methods, should also have a group name: wrap them in a <fieldset> with a <legend> such as "Size", so people hear "Size, Medium, radio button" instead of just "Medium".
What about Shopify checkout and the WooCommerce block checkout?
Shopify's checkout fields are built by Shopify, and the WooCommerce block checkout ships with labels on its fields. Problems there usually come from custom fields added by apps, plugins or theme code, so test those first and report anything you cannot change to the app or plugin developer.
How do I know which fields an automated scan flagged?
Our free scan lists each unlabeled field with the page it is on and a snippet of its HTML, so you can find it in your theme. Re-run the scan after your fix to confirm it is gone.
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
- Understanding Success Criterion 3.3.2: Labels or Instructions (W3C WAI)
- Understanding Success Criterion 4.1.2: Name, Role, Value (W3C WAI)
- Labeling Controls (W3C WAI Forms Tutorial)
- form tag (Shopify Liquid reference)
- Child Themes (WordPress Theme Handbook)