Learn HTML Forms by Building a Registration Form - Step 18

Tell us what’s happening:

not having a problem, but i have a question about for and id attribute.

so the for attribute using in label element and the id attribute using in input element.
but what if it vice versa? does it still work? or it doesnt matter.

Your code so far

<!-- file: index.html -->

    
<!-- User Editable Region -->

      <fieldset>
<label for="first-name">Enter Your First Name: <input id="first-name"/></label>
<label for="last-name">Enter Your Last Name: <input /></label>
<label for="email">Enter Your Email: <input /></label>
<label for="new-password">Create a New Password: <input /></label>
      </fieldset>

<!-- User Editable Region -->

      

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Learn HTML Forms by Building a Registration Form - Step 18

Don’t really understand the question, can you provide an example?

You can even test your example here:
https://www.w3schools.com/tags/tag_input.asp

But I think the answer is no

Hello!

I believe you are asking if you were to place the id attribute into the label element, and the for attribute into the input element would it still work.

The for attribute can only be used for the label and output elements. It would not work within the input element, as the syntax would not be correct.

Here is a link to help understand the for attribute usage.

Happy coding!

1 Like

This is what i meant! Thanks.
i really wanna know if you can use it vice versa. Turns out it doesn’t.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.