Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autocomplete example's labels aren't associated with their inputs #2531

Closed
ryandesign opened this issue Jun 3, 2023 · 4 comments
Closed
Assignees
Labels
Content:HTML issues related to HTML examples. needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.

Comments

@ryandesign
Copy link

MDN URL

https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete

What specific section or headline is this issue about?

Try it

What information was incorrect, unhelpful, or incomplete?

<label for="firstName">First Name:</label>
<input name="firstName" type="text" autocomplete="given-name">

<label for="lastName">Last Name:</label>
<input name="lastName" type="text" autocomplete="family-name">

<label for="email">Email:</label>
<input name="email" type="email" autocomplete="off">

What did you expect to see?

I should be able to click each label to focus the associated input. This doesn't work (tested in Safari 16.4) because the for attribute of each label specifies a nonexistent id. The form inputs each have name attributes but don't have id attributes.

Do you have any supporting links, references, or citations?

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label

To explicitly associate a <label> element with an <input> element, you first need to add the id attribute to the <input> element. Next, you add the for attribute to the <label> element, where the value of for is the same as the id in the <input> element.

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@ryandesign ryandesign added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jun 3, 2023
@github-actions github-actions bot added the Content:HTML issues related to HTML examples. label Jun 3, 2023
@Phil-G-94
Copy link
Contributor

Hi,

Indeed - putting an ID corresponding to the 's for attribute resolves the problem. Happy to fix the source if anyone would like to assign.

@wbamberg
Copy link
Contributor

wbamberg commented Jun 8, 2023

@Phil-G-94 , thank you for volunteering, it's all yours!

@Phil-G-94
Copy link
Contributor

Thank you @wbamberg :) Now fixed. Please see here.

Please don't hesitate if any issues with fix/further work needed.

@wbamberg wbamberg transferred this issue from mdn/content Jun 8, 2023
@github-actions
Copy link

github-actions bot commented Jun 8, 2023

It looks like this is your first issue. Welcome! 👋 One of the project maintainers will be with you as soon as possible. We appreciate your patience. To safeguard the health of the project, please take a moment to read our code of conduct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:HTML issues related to HTML examples. needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.
Projects
None yet
Development

No branches or pull requests

4 participants