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

Eric Jusic
Eric Jusic
4,350 Points

What is action attribute used for?

What is action attribute used for? I understand the method attribute, but action attribute wasn't described in any detail except just putting the name of HTML file where it exists.

What is the purpose of that attribute?

1 Answer

Ryan M
Ryan M
16,203 Points

The url in the action attribute is the location of the file/script that processes the form information. When you submit the form, this file will handle the information that the user has input and perform actions like store it in a database or send an email. You can also perform checks in this file (validation) to make sure the information submitted is valid e.g. a valid email address, and if something is wrong, you can let the user know.

Eric Jusic
Eric Jusic
4,350 Points

Makes sense now. Thank you for taking time to explain this :)