Warning More than one element using autofocus
Why only the first autofocus attribute in a document is honored, and why having more than one usually means the wrong element gets focus.
The validator flags a document where more than one element has the autofocus attribute.
Example
<!-- Flagged: two elements competing for focus -->
<input name="search" autofocus>
...
<input name="email" autofocus>
<!-- Right: pick one -->
<input name="search" autofocus>
<input name="email">Why it matters
The HTML spec is explicit that when a document contains more than one element with autofocus, only the first one encountered during parsing actually receives focus — every later one is simply ignored. This most often shows up after a page gains a second form or modal that also wants initial focus, without anyone noticing the first one is still marked autofocus too, so the newer element's autofocus silently does nothing. The fix is always the same: decide which single element should get initial focus and remove the attribute from the rest.
Frequently asked questions
Does the browser show any error for duplicate autofocus?
No — it's valid HTML syntax to put autofocus on multiple elements; the spec just defines that only the first one takes effect. There's no console warning, so the only symptom is that a later autofocus element never receives focus as expected.
What about autofocus inside a <dialog> or a component that mounts later?
An element added to the document after initial parse (for example inside a dynamically-opened dialog) can still autofocus at the point it's inserted, independent of whatever autofocused during the initial page load — this check looks at the static markup as parsed, not later DOM mutations.