Learn HTML Forms by Building a Registration Form - Step 18

Did not apply to the rest but the first line but this is the error I’m getting
" The first input element should have an id of first-name ."

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 /></label>
        <label>Enter Your Email: <input /></label>
        <label>Create a New Password: <input /></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/116.0.0.0 Safari/537.36

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

Link to the challenge:

Hi @pzak21 ,

This is the input element: <input />

According to the error message that you are receiving, the first input element should have an id attribute with a value of "first-name".

Also, the placement of for is not correct. It is an attribute that should be held in the label element.

How should the for attribute be held in the label element Im assuming in front of it?

That is correct. All attributes of an element will always be in the opening tag.

There are special self-closing tags like <img /> and <input />. You can think of these as opening tags as well that closes itself.

Still getting an error

Perhaps it’s a bug maybe?

Yeah idk I restarted it and tried again and still same error

Please refrain from posting screenshots. Instead, use the preformatted-text feature:

```
//Your code goes here
```

Let’s take a look at the demo from the page below:

Look at the label and input elements inside the form element. Notice that there are two mentions of “lfname”?

The for attribute should be inside the label element. The for attribute tells the label
“Hey, we are going to create a label for this element. The unique name of the element that this label is for is lfname” . The same time, the input will need an ID with that same name, so that the label element will know the element that it should associate itself with.

In short, the label element should have a for attribute with the name of the input element that it should be associated with. And the same input element should have an id attribute with the same name to identify itself.

Thanks appreciate it

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