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

form tag

how do you use a form tag

2 Answers

Kevin Mulhern
Kevin Mulhern
20,374 Points

The form tag wraps form elements such as inputs, text areas and buttons. Think of it as a div element for form elements in that it divides your form elements from the rest of the content on your page.

Ryan Sager
Ryan Sager
2,480 Points

The form tag is a wrapper element used to contain the form elements. For example:

<form>
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname">
</form>

The form tag is important in the use of forms, especially when you want to pass variables via a form because if an input field is put outside that form, it won't be sent with that form.