Learn HTML Forms by Building a Registration Form - Step 18

Tell us what’s happening:
My question is not passing. I have used the ‘for’ attribute in the input tag with the ‘id’ set to “first-name”, “last-name”, “email” and “new-password” respectively. Can someone please explain what I’m doing wrong here?

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Registration Form</title>
    <link rel="stylesheet" href="styles.css" />
  </head>
  <body>
    <h1>Registration Form</h1>
    <p>Please fill out this form with the required information</p>
    <form method="post" action='https://register-demo.freecodecamp.org'>

<!-- User Editable Region -->

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

<!-- User Editable Region -->

      <fieldset></fieldset>
      <fieldset></fieldset>
    </form>
  </body>
</html>
/* file: styles.css */
body {
  width: 100%;
  height: 100vh;
  margin: 0;
  background-color: #1b1b32;
  color: #f5f6f7;
}

label {
  display: block;
  margin: 0.5rem 0;
}

Your browser information:

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

Challenge: Learn HTML Forms by Building a Registration Form - Step 18

Link to the challenge:

Your for attributes should be within the opening label tag.

2 Likes

Thank you and can you tell me where the input tag would go?

It should remain inside the label element. Your code should follow the structure below.

<label for="text"><input id="text"></label>

Then check your second and third closing label tags,you haven’t done a correct closing.

I have done the same thing here but the solution isn’t passing. Could you please help me out here?

Your for values are not correct. You need to link the labels with the inputs, and the way you are going to do that is by having the for values be the same as the input id. So, whatever you see for your input id needs to be the same for that lables for value

Your label text like the Enter Your First Name: should not be in quotes

Oh! Thanks for writing this. If you don’t mind can you please drop the syntax in this case?

Hey no worries, I got it. Thanks for the help!

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