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 Form Basics Create a Submit Button

Jason Lee
Jason Lee
11,513 Points

Create a form element with an action attribute set to "index.html" and the method attribute set to "post".

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Forms</title> </head> <body> <form action="index.html" method="post">

<input type="text" id="name" name="user_name">

<textarea id="comment" id="comment" name="user_comment">

<button>Submit Comment</button>

  </form>

</body> </html>

6 Answers

Jason Lee
Jason Lee
11,513 Points

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Forms</title> </head> <body>

<form action="index.html" method="post">

<input type="text" id="name" name="user_name">

<textarea id="comment" name="user_comment">

 <button>Submit Comment</button>

  </form>

</body> </html>

Florian Goussin
Florian Goussin
8,925 Points
<form action="index.html" method="post">
</form>

there is no closed </textarea> tag it should be like below

<form method="post" action="index.html"> <input type="text" id="name" name="user_name"> <textarea id="comment" name="user_comment"></textarea> <button>Submit Comment</button> </form>

Tom Nguyen
Tom Nguyen
33,500 Points

solution:

index.html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>HTML Forms</title>
    <form action="index.html"method="post">
      <input type="text"id="name" name="user_name">
      <textarea id="comment" name="user_comment"></textarea>
      <button type="submit" value="submit">Submit</button>
    </form>
  </head>
  <body> 
  </body>
</html>
Jason Lee
Jason Lee
11,513 Points

can you write code to pass? Thanks

Florian Goussin
Florian Goussin
8,925 Points

There is no opening form tag in your code. Can you edit it ?

Otherwise you have to create it with the action attribute set to index.html and the method attribute set to post. You are not supposed to provide the inputs for this question.