HTML contact form
- Form controls the markup will hold
- 8
- Label elements, one bound to each control
- 8
- Fieldset and legend pairs around the choice groups
- 1
The counts these tools work out come from the structure the HTML standard defines for a form: one labelled control per field, a fieldset and a legend around a group of radios or checkboxes, and a name attribute on every control that is meant to be submitted. The sources under each tool link the part of the specification each rule comes from.
A contact form is the smallest useful form on the web and the one most often written slightly wrong. The markup below is the whole of it: a form element with a method and an action, a label bound to every control by its id, an email input so the browser checks the address before anything is sent, a textarea for the message and one submit button. What is left after that is the action attribute, which is where the browser posts to, and on a static site that is the part you do not have.
Open the HTML form generator Free to use. No account, no card, no trial clock.
Write the form element before you write a single field
Start with the container, because two of its attributes decide everything that follows. method="post" keeps what somebody typed out of the query string, out of browser history and out of your logs. action is the URL the browser sends the submission to, and on a static host there is nothing at your own domain that can receive it, so this attribute is the whole of the problem: it has to point at something that accepts a POST. Get those two right and the rest of the form is just fields.
One labelled control per thing you want to know
Every control gets its own label element, bound with for and id, and not a placeholder pretending to be one: a placeholder disappears the moment somebody types, which is exactly when they need to know what the field was. Choose the input type by what the answer is, because the type is what makes a phone show the right keyboard and the browser check the shape of an address. A message is a textarea, not a long text input. On the worked example beside this page, five separate questions come to 8 controls once the group of options is counted properly, and 8 label elements with them.
Decide what happens after the submit button
A form is finished when you know where the submission goes and what the person sees next. The browser will post to the action URL and then render whatever comes back, so something has to reply, and it has to reply with something a human can read. Required attributes will have caught the empty fields, but nothing has checked anything that matters yet, because the browser is not yours. Whatever receives the post has to validate it again, store it, and tell the person it arrived.
Will the HTML contact form write the markup you need?
Tell us what the form has to do and we will tell you whether Endpointo can catch it.
Writing the HTML contact form: what developers ask
What goes in the action attribute if my site is static? An absolute URL that accepts a POST. A static host serves files and cannot receive one, so the action has to point somewhere else: a serverless function you write, your own server, or an endpoint service like Endpointo Pro. Leaving it empty posts the form back at the page it came from, which on a static host does nothing useful.
Do I need method="post" or will get do? Use post for a contact form. get puts every field in the query string, which means the message ends up in browser history, server logs and any referrer header, and it caps how much can be sent. get is right for a search box and wrong for anything a person typed privately.
Does the required attribute mean I can skip checking on the server? No. required stops most people submitting an empty field and gives them an instant message, which is worth having, but it is enforced by the browser and a browser is not something you control. Anything that decides what happens to the submission has to be checked again wherever the form posts to.
Endpointo Pro
Where the submission goes next
The markup is only half a working form. Point its action at Endpointo and the posts start arriving in your inbox, with every submission and its uploads kept in one place you can search and export.
- Download the files somebody uploaded with the form
- Send notification emails without our name on them
- Come back to a form and its submissions tomorrow
- Put your own logo and reply-to address on the notifications
- Export every submission a form has ever received
- Send the notification email to more than one address
- Connect Stripe when a form needs to take a payment
- Push submissions into the tools you already run
$19per month, whole team
Start Endpointo Pro PricingEndpointo Pro is $19.00 per month. It renews automatically each month at the same price until you cancel, and the price and the renewal date are shown on the checkout page before you pay.