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

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

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

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

  </body>
</html>

2 Answers

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>

An html element is something that defines markup for a specific part of the page. For example, the '<p>' tags create a paragraph element or the '<img>' tags create an image element.

Therefore, our form can be created using the 'form' tags, like this:

<form></form>

An attribute is something we can add to those tags to further define the element. For example, if we want to add a class to a paragraph tag, we would do so like this:

<p class="nameofclass"></p>

So, if the question asks us to create a form element with an action and method attribute, we would do so like this:

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

I hope this helps!