Lesson 9 of 15

Forms

HTML Forms

Forms collect user input. The <form> tag wraps all form controls:

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

Key elements:

  • <form> — the container, with action (where to send data) and method (GET or POST)
  • <input> — a form field (self-closing)
  • <label> — a text label for an input; for links it to an input's id
  • <button type="submit"> — submits the form

The placeholder attribute shows hint text inside an input:

<input type="text" placeholder="Enter your name">

Your Task

Create a form with:

  • A <label> and a <input type="text">
  • A submit button
HTML preview loading...
Loading...
Click "Run" to execute your code.