Forms - HTML Tutorial
Forms are how websites collect information from visitors: contact forms, newsletter sign-ups, search boxes, surveys, booking requests and checkout pages are all forms.
In this chapter you'll learn how to build forms with HTML. You'll create text fields, checkboxes, menus and buttons, make sure every field is clearly labeled and use the browser's built-in checks to catch mistakes before a form is sent.
Note
HTML builds the form and sends the information, but receiving and processing it, such as sending an email or saving to a database, happens on a web server using a language like PHP, Python or Node.js. That's outside the scope of this tutorial. Everything in this chapter still works on your own computer, so you can build and test your forms as you go.
By the end of this chapter, you'll be able to:
- create a form and understand what happens when it's submitted
- connect every field to a clear label
- choose the right type of field for each piece of information
- group related fields together
- check what visitors enter using built-in validation
Sections in This Chapter
- Form Basics
-
Build your first form with a text field, a label and a submit button, and see how form data is sent.
- Form Controls
-
Explore the different kinds of field: email, number, date, checkboxes, radio buttons, drop-down menus, text areas and more.
- Form Validation
-
Make fields required, set limits and formats, show helpful hints and style valid and invalid fields.