Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Forms HTML Mastery

Add text input to form.

The task is to add a text input to a form. The task prior to this one was to add a form tag, which was done correctly; so I know the problem isn't the form tag. I'm not sure what is wrong with my text input. Can someone check this?

Can you paste your code here for us to see? :)

<form>
<input type=β€œtext” name=β€œusername”>
</form>

Hmm, that looks okay to me. Let me try running through the challenge myself.

3 Answers

Okay, I think it might be a quirk with the challenge. I don't think it wants the name attribute you have, just the type="text" part. This should pass the rest of the challenge:

<form>
    <input type="text" value="Hello World">
</form>

Happy coding!

Do you know why the value attribute was needed here? It wasn't discussed in the video. Also, there was a question on the Quiz about which statement was correct for adding a text input. The correct answer didn't have a value attribute here either.

Jeremy Canela
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jeremy Canela
Full Stack JavaScript Techdegree Graduate 30,766 Points

To create an input field, just create a tag called input and specify the type of input. Example:

<form action="">
    <input type="text">
</form>

<form action=""> <input type="text"> </form>

I tried this first, but it was wrong.

<form action=""> <input type="text" value="Hello World"> </form>

Not sure why, but this was correct. Thank you.