Survey Form - Build a Survey Form

Tell us what’s happening:
Describe your issue in detail here.
I was told that my name label should contain text that describes the input.
I did that but it didn’t work.
Why and what should I do?
Your code so far

<!-- file: index.html -->
<html>
  <head>
    <link rel="stylesheet" href="styles.css">
    <title> freeCodeCamp Survey Form</title>
    </head>
    <body>
<h1 id="title">Survey Form</h1>
<p id="description">Thank you for taking time to help us improve the platform.</p>
<form id="survey-form">
<label id="name-label" for="name"><input required type="text" id="name" name="name" placeholder="Enter your name"></label>
<label  for="email" id="email-label" your email><input required type="email" id="email" name="email" placeholder="Enter your email"></label>
<label for="age" id="number-label"> <input min="13" max="60"  type="number" id="number" name="number" placeholder="Age"></label>
  </form>
  </body>
  </html>


/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.183

Challenge: Survey Form - Build a Survey Form

Link to the challenge:

<label id="name-label" for="name"><input required type="text" id="name" name="name" placeholder="Enter your name"></label>

Where do you see text that describes the input?

Keep in mind that text for an element is usually between the opening and closing tags.

“your email” does not belong where it is.

Thanks for replying but I still don’t understand

If I told you to give an h1 element the text “Hello World” then you would (hopefully) code it as

<h1>Hello World</h1>

Do you see how the text for the element is between the opening and closing tags? You need to do the same thing for the label elements.

P.S. You can have an input element and also text inside of a label element.

@Glory1

Hello!

I am not sure if this will help you. But, it is how I completed my Survey Project.
After filling in the basic HTML Template, I went step by step with what it said I should have in the document. Every few steps, I would run it to see if it took, or if I needed to make changes.

I used some of my previous steps to guide me in how to use the styles.css to get a bit cleaner look, too.

It is not perfect, but passed. I will keep updating it even though it has the necessary requirements and has passed the certification requirements.

Hope some of this helps you.

Happy coding!

So how do I make the name-label contain text that describes the input or what attribute should I use?

What is the input asking for? That’s the text I would use in the label. Add that text to the label just like you would add text to an h1 element.

I understand everything you said above but what text?

Any text. It is your choice what it says, as long as the text is there.
Maybe take a look at the example page in the description to get an idea of what to put as a headline etc.

It’s your survey form, so you should know what the input is asking for :slightly_smiling_face:

Forget that you have placeholder text in that input. (Personally, I would not have it there at all, but that’s another story). Without the placeholder text, the text box is just there by itself. How will people know what you want them to enter in the box? They will know by the text you add to its label.

I have done that but it’s still not working.

<html>
  <head>
    <link rel="stylesheet" href="styles.css">
    <title> freeCodeCamp Survey Form</title>
    </head>
    <body>
<h1 id="title">Survey Form</h1>
<p id="description">Thank you for taking time to help us improve the platform.</p>
<form id="survey-form">
<label id="name-label" for="name" input="Your name"><input required type="text" id="name" name="name" placeholder="Enter your name"></label>
<label  for="email" id="email-label" your email><input required type="email" id="email" name="email" placeholder="Enter your email"></label>
<label for="age" id="number-label"> <input min="13" max="60"  type="number" id="number" name="number" placeholder="Age"></label>
  </form>
  </body>
  </html>


You added “Your name” as a value of the input attribute. This isn’t what I suggested you do. I suggested you add it as text in the label, which means adding it between the opening and closing tags (just like you would do with an h1 element).

1 Like

After trying to figure this out , I have finally done it.
Thanks :+1:for your help @bbsmooth, @ooDanieloo and for your good advice: @anon42932716.
:smiley:

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