HTML Forms

cheriii's avatar
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.

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
    • Beginner Friendly.
      7 hours

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:

Rendered output of above snippet

Video Walkthrough

Watch this video for a step-by-step tutorial on creating HTML forms.

All contributors

Contribute to Docs

Learn HTML on Codecademy

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
    • Beginner Friendly.
      7 hours