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 Form Element

Chandler Tate
Chandler Tate
3,963 Points

I'm still a bit confused on what action and method mean when creating a form tag in HTML

Is there anyone that is able to clear up the confusion on this for me? I'm a tad confused on what the two mean, action and method, and why we use them exactly.

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

Thanks for the help!!! :)

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Action is going to contain the source of the form performing the action. In your case, it's index.html. The method is either going to be post or get. Either we're getting information or putting that information somewhere. More technical documentation can be found by the w3c here:

https://www.w3.org/TR/html401/interact/forms.html

Steven Parker
Steven Parker
231,275 Points

The action is for the URI that the form data will be sent to. It may help to think of it as an "address". It's where the "action" will be taken on the form data.

The method is how the data will be sent, and to a certain extent what we expect to happen with it. The most common methods by far are GET and PUT. The GET method is mostly about asking a server to send us something (such as current weather info), and PUT is mostly about giving something to the server (an online purchase order, perhaps).

Does that help clear it up?

Chandler Tate
Chandler Tate
3,963 Points

Awesome, thanks for the help! As far as the action goes, that just specifies which page the form is being accessed on? For example, if the form was on the imaginary page of about.html, the action would be action="about.html" ?