How an HTML contact form gets submitted
A <form> element on its own doesn't send email. When someone clicks submit, the browser collects every field that has a name attribute and sends it to the URL in action, using the method you set. For a contact form that's a POST with a body like name=Jane&email=jane%40example.com&message=Hi.
Something has to be listening at that URL. A static site on GitHub Pages or an S3 bucket can serve your HTML but can't accept a POST, so the submission goes nowhere. You have three options: write your own server route, deploy a serverless function, or point action at a form backend that stores the submission and forwards it. The tradeoffs are covered in How to Handle Form Submissions Without a Backend.
The generator above writes the form half. The name attributes become the keys you see in your inbox or spreadsheet, so keep them short and stable: email, not Your Email Address.
The contact form fields that matter
Most contact forms need three fields: name, email, and message. Each extra field costs you completions, so add phone, company, or a topic dropdown only when you'll act on the answer.
- Email uses
type="email", so phones show a keyboard with@and the browser checks the format before sending. - Autocomplete tokens (
name,email,tel,organization) let browsers fill fields in one tap. - Message is a
<textarea>, so longer messages stay readable while typing. - Dropdowns start with an empty option, so
requiredforces a real choice instead of quietly sending the first value. - Consent checkbox: add one if your privacy policy says you ask for it. It sends
yeswhen ticked and nothing when it isn't.
Spam protection: honeypot and CAPTCHA
A honeypot is a field people can't see but bots fill in, because they complete every input they find. The generator moves it off-screen instead of using display:none (some bots skip fields hidden that way), takes it out of the tab order with tabindex="-1", hides it from screen readers with aria-hidden="true", and turns off autocomplete. The name hp_company_site is deliberately odd so browsers and password managers leave it alone.
In OSForms the honeypot is opt-in per form. Open the form's Settings and set Honeypot Field Name to hp_company_site; the names must match exactly. When a submission arrives with that field filled in, OSForms returns a normal success response but doesn't store it, so the bot gets no signal that it was caught.
Honeypots stop basic bots. For targeted spam, add a CAPTCHA. OSForms verifies Google reCAPTCHA (v2 and v3), hCaptcha, and Cloudflare Turnstile with your own secret key. Add the provider's widget to the form with your site key. OSForms picks the verifier from the token field the widget posts (g-recaptcha-response, h-captcha-response, or cf-turnstile-response) and strips the token before storing the submission. The secret is saved on the form as recaptchaSecret, one setting for all three providers, through PATCH /api/v1/forms/{id}. Each form is also rate limited per IP address, 10 submissions a minute by default.
Accessibility checklist
- Every control has a visible
<label>tied to it with matchingforandid. Placeholders are hints, not labels: they vanish as soon as someone types. - Required fields carry the
requiredattribute, so screen readers announce them. The visual asterisk isaria-hiddenand explained in a note above the fields. - Inputs use the right
typeandautocompletetoken (WCAG 1.3.5, Identify Input Purpose). - Focus stays visible. The basic CSS adds a 2px outline on
:focus-visible. - Submit is a real
<button type="submit">, so Enter and Space work without extra code. - In the fetch version the result message sits in a
role="status"region, so screen readers read it out. - The honeypot is out of the tab order and hidden from assistive tech, so keyboard and screen reader users never land on it.
Connect the form to OSForms in 3 steps
- Create a form. Sign up free, create a form, and copy its endpoint:
https://osforms.com/api/v1/f/your-slug. - Paste the endpoint. Put it in the Form action URL field above, or replace
YOUR_FORM_SLUGin the code you copied. In the form's Settings, set the Honeypot Field Name tohp_company_site. For the plain HTML version, also set a Redirect URL: OSForms then answers with a 303 redirect to your thank-you page instead of showing JSON. - Add integrations. Send each submission to your inbox with your own Resend key (contact form email with Resend), append rows to a Google Sheet, or POST to a signed webhook. Every submission is also stored in your dashboard.
The free plan covers 100 submissions a month with every integration included. For a longer walkthrough that ends with email in your inbox, read How to Make an HTML Contact Form That Sends Email.