Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Duplicate IDs breaking form label associations: how to fix

PRF-326Low impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

A label is tied to a form field by matching two values: the label's for attribute and the field's id. The browser looks up the id and takes the first element that has it. If two fields share the same id, the second one is never reached by its label.

This often happens when the same form is added twice on a page (for example in a header popup and in the footer), when a form is copied between pages, or when a plugin generates fixed IDs like email or name.

Broken: two fields share id="email"html
<form id="popup-form">
  <label for="email">Email</label>
  <input type="email" id="email" name="email">
</form>

<form id="footer-form">
  <label for="email">Work email</label>
  <input type="email" id="email" name="email">
</form>

Why it costs you leads or sales

The impact is usually low, but it is real for some visitors. Clicking the footer label moves focus up to the popup field, which may be hidden or off screen. Screen reader users may hear the wrong or no name for a field. Autofill and form scripts that select by id can also fill or read the wrong input.

Label behaviour with duplicate vs unique IDs

Duplicate IDs

  • Footer label focuses the popup field
  • Screen reader may announce the wrong field name
  • Scripts using getElementById reach the first field only

Unique IDs

  • Each label focuses its own field
  • Each field is announced with its own name
  • Scripts target the intended field
A label that points at the wrong field

The visitor clicks a label, but focus lands on a different field.

How to check if your site has it

Open the page, press F12 and paste this into the Console tab. It lists every id used more than once.

List duplicate IDs on the current pagejavascript
const seen = {};
document.querySelectorAll('[id]').forEach(el => {
  seen[el.id] = (seen[el.id] || 0) + 1;
});
console.table(Object.entries(seen).filter(([id, n]) => n > 1));

You can also run an accessibility checker such as the axe DevTools browser extension or Lighthouse (Chrome DevTools, Accessibility category) and look for duplicate id or label results. Test the page in every state: open popups, tabs and accordions can add forms after load.

Quick manual test
  • Click each label and confirm the cursor lands in its own field
  • Check pages where the same form appears twice
  • Open popups and slide-ins, then rerun the console script
  • View source of the rendered page, not just the template

How to fix it

Fix duplicate IDs on form fields
  1. List the repeated IDs

    Use the console script above and note which fields and forms share each id.

  2. Give each field a unique id

    Add a suffix that tells forms apart, such as email-popup and email-footer.

  3. Update each label's for attribute

    Make every for match the new id of its own field exactly. Case matters.

  4. Or wrap the input in the label

    A label that contains its input needs no id at all, which avoids the problem.

  5. Check scripts and CSS

    Search for any code or styles that used the old ids and update them.

Fixed: unique IDs, or a wrapping labelhtml
<form id="popup-form">
  <label for="email-popup">Email</label>
  <input type="email" id="email-popup" name="email">
</form>

<form id="footer-form">
  <label>Work email
    <input type="email" name="email">
  </label>
</form>
Where to make the change
  1. Check the form plugin

    In plugins such as Contact Form 7, Gravity Forms or WPForms, field IDs are set in the form editor or generated per form. Avoid embedding the same form twice on one page, or use the plugin's setting for a custom field id or CSS class.

  2. Check theme templates

    If a header and footer both include the same form template, edit the theme or child theme so each copy gets a different id.

How to confirm it's fixed

Verify the fix
  1. Rerun the console script

    The table should be empty.

  2. Click every label

    Focus should land in the matching field each time, including in popups.

  3. Rerun axe or Lighthouse

    Duplicate id and label warnings should be gone.

  4. Submit a test entry

    Confirm each form still submits and any scripts still work after the rename.

How to prevent it happening again

Habits that keep IDs unique
  • Never hard-code generic ids like email or name in reusable components
  • Add an accessibility linter or axe check to your build or QA routine
  • Test pages after adding popups, widgets or new form embeds
  • Prefer wrapping inputs in labels where the design allows
  • Recheck forms after theme, plugin or page-builder updates

How FunnelGuard handles this

This issue is outside what FunnelGuard checks. FunnelGuard runs your real customer journeys on a schedule and checks steps, tracking hits and test lead delivery. Markup quality such as duplicate IDs needs a different kind of tool: an accessibility or HTML validation scanner, such as axe, Lighthouse or a WCAG audit crawler.

If a broken form stops leads from arriving, a FunnelGuard journey check on the form is a separate and useful safeguard. A free plan covers 1 site and 2 journeys.

Questions people ask

Why does clicking a label focus the wrong input?

Two fields on the page probably share the same id. The label's for attribute looks up that id and the browser picks the first match, so focus goes to the first field even if the label sits next to the second.

Can two elements have the same id in HTML?

No. The HTML specification requires every id on a page to be unique. Browsers will not throw an error, but features that rely on ids, like label association, anchors and scripts, behave unpredictably.

How do I find duplicate IDs on a page?

Run a short console script that counts every [id] value and lists those used more than once. You can also use axe DevTools or Lighthouse in Chrome, which report duplicate ids and broken label links.

Do duplicate IDs hurt accessibility?

Yes, when they affect labels or ARIA references. A screen reader may announce the wrong name for a field or fail to link a label to its input, which makes the form harder to complete.

How do I fix duplicate IDs when the same form appears twice?

Give each copy unique ids, for example with a suffix like -popup and -footer, and update each label's for to match. Alternatively, wrap each input inside its label so no id is needed.

Do duplicate IDs reduce form conversions?

Usually only slightly. The effect is largest when a label click sends focus to a hidden field, or when assistive technology users cannot tell fields apart. It is a quick fix worth making.

Can FunnelGuard detect duplicate IDs?

No. This is outside what FunnelGuard checks. Use an accessibility scanner or HTML validator for markup problems like this, and use FunnelGuard to confirm the form still works and leads arrive.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.