Learn HTML Forms by Building a Registration Form - Step 18

Tell us what’s happening:
I’m having trouble with the “id” element.

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 id="first-name" for="first-name" /></label>
        <label>Enter Your Last Name: <input id="last-name" for="last-name" /></label>
        <label>Enter Your Email: <input id="email" for="email" /></label>
        <label>Create a New Password: <input id="new-password" for="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/113.0.0.0 Safari/537.36 OPR/99.0.0.0

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

Link to the challenge:

Welcome to our community,

to clear things first out, id="value" is an attribute as you add attributes in elements like <input> or <label>. You are close to pass this but you added the attributes id="" and for="" in one element which in this case is <input> but you have to create a connection between <input> and <label>. To pass this test, you have to delete all the id="" attributes from your <input> element and add them to your <label> element.

at the end every <label> element should have an attribute of id="" and every <input> element should have a for="" attribute.

Thank you for your reply. I put all the id attributes in the first element. But it still says: The first input element should have an id of first-name.

can you show me your new code, so I can have a look

I see the problem now. ID’s should be inside the <input> element and FOR’s should be in the <label> element. I learned something new as well.

3 Likes

Oh yeah. Thanks for spending time with me.

2 Likes

Can you add your code here so I can see what it looks like. I’m adding the id’s to the input and for to the label but it’s still telling me that I’m wrong.