A form isn't just inputs—it's a carefully orchestrated system of labels, containers, and hidden attributes that make the internet work. Think of it as a bureaucracy, but digital.
<form>
The parent element. Contains everything and tells browsers where to send data. Without it, your inputs are orphans.
<fieldset>
Groups related inputs together. Like putting all your address fields in one box. Also draws a cool border.
<legend>
The title of a fieldset. Describes what the grouped inputs are for. Required if you use fieldset (but nobody checks).
<form action="/process" method="POST">
<fieldset>
<legend>Tell Us About You</legend>
<!-- Inputs go here -->
</fieldset>
</form>
Form Attributes: The Secret Sauce
Every <form> needs at least two attributes to be useful. Otherwise it's just decoration.
<form
action="/api/submit"
method="POST"
enctype="multipart/form-data"
autocomplete="on"
novalidate
>
method="GET" vs "POST"
GET: Data in URL (example.com?name=John). Use for searches, filters, bookmarkable pages.
POST: Data in request body. Use for logins, signups, credit cards, anything secret.
Mix them up and watch your passwords appear in browser history.