Learn HTML Forms by Building a Registration Form - Step 18

My hint says as follows

" The first input element should have an id of first-name"

and my code so far is like this

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

what am I doing wrong?

<!-- 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'>
      <fieldset>
        <label id="first-name">Enter Your First Name: <input /></label>
        <label id="last-name">Enter Your Last Name: <input /></label>
        <label id="email">Enter Your Email: <input /></label>
        <label id="new-password">Create a New Password: <input /></label>
      </fieldset>
      <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/107.0.0.0 Safari/537.36 Edg/107.0.1418.35

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

Link to the challenge:

You are adding the id attribute to the label. But they said to add it to the input element.

I had initially tried that, and when I do this is what I get in response

" The first label element should have a for attribute with a value of first-name ."

Yes that hint is also accurate.
You need to link the input with the label by adding a for attribute to the label that matches the id attribute in the input.

Ok, it seems I’m a little bit lost, I can’t seem to figure it out…can I get a simpler hint? maybe I don’t understand the language

I can give you an example?

<label for=“question”>What’s the question? <input type=“text” id=“question”></label>

Above is how you would link a label element and an input element using a for attribute and an id attribute.

that was a lot of help and I got it now, thanks a lot

1 Like

this is a different problem. I have the following code

<input id="name" type="text"> Enter your name </input>

and I’m being told that my “name” should require input…doesn’t it have input already?

I’m gonna guess that you have that concept in reverse. The input requires a name attribute.
If you are still stuck please click on the Ask For Help button again in the new challenge.
Also please mark this topic solved by picking a response and marking it as the solution (using the Solution checkmark on that specific post)