HTML Forms
A form groups controls that collect information for a defined purpose. HTML can describe fields and basic validation, but saving or processing their values requires application logic.
How it works
- Give every control a meaningful label. A matching label for and control id connect the visible wording to the field.
- The name attribute determines the key sent with a control’s value. An id alone does not make a field part of the submitted data.
- Use a deliberate action and method. Your server must implement the endpoint, validate input, and apply appropriate authentication and CSRF protection for state-changing requests.
A practical example
<form action="/workshop-signup" method="post">
<label for="guest">Your name</label>
<input id="guest" name="guest_name" autocomplete="name" required>
<label for="email">Email address</label>
<input id="email" name="email" type="email" autocomplete="email" required>
<button type="submit">Request a place</button>
</form>
The browser can check required fields and an email-shaped value before attempting submission. /workshop-signup is an illustrative endpoint that you must implement; this snippet does not register anyone by itself.