HTML

How to Create Forms in HTML for Beginners

A beginner's guide to HTML forms: how the <form> tag sends data for logins, sign-ups and contact messages, starting from the basics.

RazakTerra
Reading time
1 min read
Comments
Discussion
How to Create Forms in HTML for Beginners
On this page
  1. Basic Form Structure
  2. GET vs POST
  3. Simple Contact Form Example
  4. Quick Tips

Basic Form Structure

HTML
<form action="/submit" method="POST">
  <!-- form fields go here -->
  <button type="submit">Submit</button>
</form>
  • action → where the data will be sent
  • method → how the data is sent (GET or POST)

GET vs POST

  • GET → sends data through the URL (good for search forms)
  • POST → sends data in the background (better for login, contact, or sensitive info)

Simple Contact Form Example

HTML
<form action="/contact" method="POST">
  <label for="name">Name:</label>
  <input type="text" id="name" name="name" />

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

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

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

Quick Tips

  • Always use a <label> so users know what each field is for.
  • Give every input a name attribute, this is what gets sent with the data.
  • Use POST for forms that handle private information.
  • The action can point to a backend file or API endpoint.

Written by

Razak

Writes about the web, slowly, and builds small tools on the side.

Discussion

Comments

Loading comments…

Keep reading

1 min
HTML

HTML Form Validation Without JavaScript

HTML5 has built-in form validation: required fields, length and number limits, and format patterns, all without a single line of JavaScript.

Read article