CPCODELAB
HTML

Forms: action, method, and How Submission Works

9 min read

HTML Forms

Forms allow users to send data to a server. The <form> element wraps all the inputs. Its two key attributes are action (where to send the data) and method (how to send it — GET or POST).

html
<form action="/submit" method="POST">
  <label for="name">Full Name</label>
  <input type="text" id="name" name="name" />

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

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

GET vs POST

  • GET — Data is appended to the URL as query strings (e.g. /search?q=html). Use for searches or bookmarkable requests. Never for passwords.
  • POST — Data is sent in the request body, not the URL. Use for logins, registrations, and anything sensitive.
  • Without a method, the form defaults to GET.

The name attribute on each input is what gets sent to the server. Without a name, the field's value is ignored during submission.

Ready to test yourself?
Practice HTML— quiz & coding exercises