Form Basics
Forms collect user input and send it to a server. Understanding form structure is essential for interactive web applications.
Basic Form Structure
Loading HTML Playground...
Form elements:
<form>- Container for form controlsaction- URL to send data tomethod- HTTP method (get or post)
The Label Element
Loading HTML Playground...
Labels are essential:
- Screen readers announce them
- Clicking label focuses the input
- Use
for+idor wrap the input
Basic Input Types
Loading HTML Playground...
Placeholder and Value
Loading HTML Playground...
placeholder- Hint text (disappears on focus)value- Pre-filled value
Required Fields
Loading HTML Playground...
The required attribute:
- Prevents form submission if empty
- Shows browser validation message
Form Grouping with Fieldset
Loading HTML Playground...
<fieldset>- Groups related fields<legend>- Title for the group
Exercise: Create a Contact Form
Create a simple contact form:
Loading HTML Exercise...
Forms are the primary way to collect user input on the web!

