Build a survey form-Failing Test

Tell us what’s happening:
Currently working on certificate projects (Build a survey form). My code do not seem to be wrong. All test have passed, remaining test 10 which says:
10. For the name, email, and number input fields inside the form I can see corresponding labels that describe the purpose of each field with the following ids: id=“name-label”, id=“email-label”, and id=“number-label”.
#name-label is not defined : expected null to not equal null
AssertionError: #name-label is not defined : expected null to not equal null

Your code so far
This is my code for the test:

<p>Name:
    <label for="name-label">
      <input id="name" type="text" name="name" placeholder="Enter your name" required>
      <label>
        </p>
    
  <p>Email:
    <label for="email-label">
      <input type="email" id="email" name="email"  placeholder="Enter your Email" required/>
    </label></p>
<p>Number:
  <label for="number-label">
    <input type="number" id="number" min="5" max="100" placeholder="Age" required/>
  </label></p>

I don’t know it is displaying that label for name is not defined.
How do i fix this?

Your browser information:

Challenge: Build a Survey Form

Link to the challenge:

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums


The for attribute value on the label should match the id value on the input.


Thank you Lasjorg for that correction and solution, but the problem is that test(4) wants me to specify label-id as=“label-name” while test (10) wants the input-id to be =“name”. So if i match label id and input id to be the same, one of the test keeps failing.

you can’t have multiple elements with the same id, that’s correct

but the for attribute of the label should match the id of the input element

you have not given an id to your label elements

you are also not using the label elements, you should put the text in the labels, instead of in a paragraph, so that clicking on the text will select the input element

Please the rule below:

...

**User Story #4:** Inside the form element, I am required to enter my name in a field with `id="name"` .

...

**User Story #10:** For the name, email, and number input fields inside the form I can see corresponding labels that describe the purpose of each field with the following ids: `id="name-label"` , `id="email-label"` , and `id="number-label"` .

...

If test 4 pass, test 10 fails and vice-versa due to the different id's. If i use the same id for label and input field, one must fail

...

you CANNOT use the same id for two different elements
it ask to use different id, you are not doing that, one is id="name" the other id="name-label"

the for attribute is not the same as the id attribute

also, the label element should contain text

<p>Thanks alot, problem solved</p>

if you want to get better you can also submit your project for peer review in the #project-feedback subforum