Forms
Published Aug 4, 2021Updated May 15, 2024
Contribute to Docs
In HTML, forms are used for gathering and sending user input to an external source (like a server) for processing. This is done with the <form>
element, which contains various labels and inputs.
Syntax
<form><!-- Form elements --></form>
Example
The following is an example of an HTML form that features <input>
elements:
<!DOCTYPE html><html><head> </head><body><form method="post" action="http://server1">Enter your name:<input type="text" name="fname" /><br />Enter your age:<input type="text" name="age" /><br /><input type="submit" value="Submit" /></form></body></html>
The rendered output of above looks like this:
Video Walkthrough
Watch this video for a step-by-step tutorial on creating HTML forms.
All contributors
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn HTML on Codecademy
- Career path
Front-End Engineer
Front-end engineers work closely with designers to make websites beautiful, functional, and fast.Includes 34 CoursesWith Professional CertificationBeginner Friendly115 hours - Free course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner Friendly7 hours