<htmlstart/>

Forms

Collect user input with HTML forms.

Basic Form

<form action="/submit" method="post">
  <label for="name">Name:</label>
  <input type="text" id="name" name="name" required>

  <label for="email">Email:</label>
  <input type="email" id="email" name="email" required>

  <label for="message">Message:</label>
  <textarea id="message" name="message" rows="4"></textarea>

  <button type="submit">Send</button>
</form>

Common Input Types

TypeUse for
textSingle-line text
emailEmail address (validates format)
passwordPassword (hides characters)
numberNumeric input
checkboxBoolean on/off
radioChoose one from a group
fileFile upload
submitSubmit button
dateDate picker
Always pair <label> with <input> using matching for and id attributes — it makes forms accessible and expands the click area.
🧩

Test Yourself

4 questions
Q1.Which attribute defines where form data is submitted?
Q2.Which HTTP method sends form data in the URL query string?
Q3.Which input type creates a checkbox?
Q4.Which HTML attribute makes a form field mandatory?