Learn HTML Forms by Building a Registration Form - Step 18

Please help whenever I add the for attribute it still does not accept my code. Any help please:

Following accessibility best practices, link the input elements and the label elements together using the for attribute.

Use first-name, last-name, email, and new-password as values for the respective id attributes.

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <title>Registration Form</title>
    <link rel="stylesheet" href="styles.css" />
    <h1>Registration Form</h1>
    <p>Please fill out this form with the required information</p>
    <form method="post" action='https://register-demo.freecodecamp.org'>
        <label>Enter Your First Name: <input for="First-Name" id="first-name"></label>
        <label>Enter Your Last Name: <input for="last-name" id="last-name"></label>
        <label>Enter Your Email: <input for="email" id="email"></label>
        <label>Create a New Password: <input for="new-password" id="new-password"></label>
/* 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/ Safari/537.36

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

Link to the challenge:

hi there,
how about giving each label-elementopening-tag a for attribute with adequate value?

Only the id should be in the input. The for attribute should be inside the label.
And the value of the for attribute should be identical to the value of the id here.

1 Like

Thank you! It worked now

1 Like

Hello the for attribute was supposed to be inside label opening tag…I tried that and it worked. Thank you!

1 Like

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