Step 1 Start From a Template
Pick Contact form, Sign-up, Newsletter, Feedback, Job application or Event RSVP. Or keep the starting contact form and change it. If you load a template by mistake, the Undo button at the top brings your form back.
Templates Start from a ready-made form, then change anything
Fill it in and press the button to see the browser's checks. Nothing is sent from the preview.
<style>
.my-form {
display: flex;
flex-wrap: wrap;
gap: 18px 16px;
box-sizing: border-box;
width: 100%;
max-width: 560px;
margin: 0;
font-size: 16px;
line-height: 1.5;
color: #111827;
}
.my-form > * {
flex: 1 1 100%;
min-width: 0;
}
.my-form > .my-form-half {
flex: 1 1 calc(50% - 8px);
min-width: min(100%, 13rem);
}
.my-form-heading {
margin: 0;
font-size: 1.5em;
line-height: 1.25;
}
.my-form-note {
margin: 0;
font-size: 0.875em;
color: #4b5563;
}
.my-form-label {
display: block;
margin: 0 0 6px;
padding: 0;
font-weight: 600;
}
.my-form-req {
color: #b91c1c;
}
.my-form-input {
box-sizing: border-box;
display: block;
width: 100%;
margin: 0;
padding: 10px 12px;
font: inherit;
line-height: 1.4;
color: #111827;
background-color: #ffffff;
border: 1px solid #6b7280;
border-radius: 6px;
}
textarea.my-form-input {
resize: vertical;
}
select.my-form-input {
padding: 10px 40px 10px 12px;
-webkit-appearance: none;
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%234b5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 12px center;
background-size: 12px 8px;
cursor: pointer;
}
.my-form-input::placeholder {
color: #6b7280;
opacity: 1;
}
.my-form-input:focus {
outline: 2px solid transparent;
border-color: #4f46e5;
box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.3);
}
.my-form-input:user-invalid {
border-color: #b91c1c;
}
.my-form-actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.my-form-button {
padding: 10px 20px;
border: 2px solid #4f46e5;
border-radius: 6px;
font: inherit;
font-weight: 600;
line-height: 1.2;
color: #ffffff;
background-color: #4f46e5;
cursor: pointer;
}
.my-form-button:hover {
background-color: #463eca;
border-color: #463eca;
}
.my-form-button:focus-visible {
outline: 2px solid #4f46e5;
outline-offset: 2px;
}
</style>
<form class="my-form" method="post">
<h2 class="my-form-heading">Contact us</h2>
<p class="my-form-note">Fields marked * are required.</p>
<div class="my-form-field my-form-half">
<label for="name" class="my-form-label">Name <span class="my-form-req" aria-hidden="true">*</span></label>
<input type="text" id="name" name="name" class="my-form-input" autocomplete="name" required>
</div>
<div class="my-form-field my-form-half">
<label for="email" class="my-form-label">Email <span class="my-form-req" aria-hidden="true">*</span></label>
<input type="email" id="email" name="email" class="my-form-input" placeholder="[email protected]" autocomplete="email" required>
</div>
<div class="my-form-field">
<label for="topic" class="my-form-label">What is it about?</label>
<select id="topic" name="topic" class="my-form-input">
<option value="" disabled selected hidden>Choose a topic…</option>
<option value="general-question">General question</option>
<option value="support">Support</option>
<option value="feedback">Feedback</option>
</select>
</div>
<div class="my-form-field">
<label for="message" class="my-form-label">Message <span class="my-form-req" aria-hidden="true">*</span></label>
<textarea id="message" name="message" class="my-form-input" placeholder="How can we help?" minlength="10" rows="5" required></textarea>
</div>
<div class="my-form-actions">
<button type="submit" class="my-form-button">Send message</button>
</div>
</form>
An HTML form is the part of a page where people type something and press a button: a contact form, a newsletter
sign-up, a job application. It's a <form> with fields inside, like <input>,
<textarea> and <select>, and a submit button.
This builder writes that code for you. Start from a template or add fields one by one, set the labels and rules, pick
a look, and try the form in the preview. Then copy clean HTML and CSS with a label for every field, a
<fieldset> around every group and sensible autocomplete hints. It all runs in your
browser, and your last form is remembered for next time.
Five steps. The preview shows the same code you copy.
Pick Contact form, Sign-up, Newsletter, Feedback, Job application or Event RSVP. Or keep the starting contact form and change it. If you load a template by mistake, the Undo button at the top brings your form back.
Click a field to open it. Type the Label, an optional Placeholder and
Help text (it's read out with the field). The name is made from the label, or type
your own. Switch on Required, set Half width to put two fields side by side, and
add limits like a minimum length, a number range or a pattern. Dropdowns, checkboxes and radios take one option
per line.
Put your server's or form service's address in Action, pick POST or GET, and write the button text. Switch on the spam trap if you like. Then choose a theme (Simple, Rounded card, Dark, Minimal underline or Big touch-friendly), an accent color, the form width and the space between fields.
Fill in the preview and press the button: the browser shows its own messages for empty or wrong fields, and wrong answers get a red border once you leave the field. Nothing is sent from the preview. Then open HTML & CSS, pick Class + <style> or Inline styles, and press Copy all. The notes under the code point out anything to fix, like a missing action.
💡 Inline styles can't do :focus, :hover or :user-invalid, so with
inline output the focus ring and the red border for wrong answers are left out. Class + <style> keeps them.
A form has three jobs: show the fields, check them, and send them. When someone presses the submit button, the
browser collects every field that has a name and sends it as name=value pairs to the
address in action, using the method you set.
The code:
<form action="/subscribe" method="post">
<label for="email">Email</label>
<input type="email" id="email" name="email" required>
<button type="submit">Subscribe</button>
</form> You'll see (sending is off in this example):
/subscribe on your own site, or a full address. Leave it out and the form sends to the page it's on./search?q=shoes. Good for search and filters, because the result can be bookmarked.
The right type gives people the right keyboard on a phone, a date picker where it helps, and a free
check before the form is sent. Here are the ones the builder makes:
| Type | Use it for | Good to know |
|---|---|---|
text | Names, short answers | The default. Add autocomplete="name" and browsers can fill it in. |
email | Email addresses | Checks there is an @ and a domain, and phones show an @ key. |
password | Passwords | Hides what you type. Use autocomplete="new-password" on sign-up forms. |
tel | Phone numbers | Shows a number pad on phones but doesn't check the format (numbers differ by country). |
number | Amounts, quantities, ages | Has arrows and min/max. Not for card numbers or ZIP codes: those are text with inputmode="numeric". |
url | Web addresses | Expects a full address with https://. |
date | One day | The browser shows its own date picker, and min/max limit the range. |
<textarea> | Longer messages | Several lines. rows sets the height. |
<select> | One answer from a long list | Add a first option with value="" so required works. |
radio | One answer from a few | Same name for the whole group, inside a fieldset. |
checkbox | Yes/no, or several answers | Sends nothing when unticked. |
file | Uploads | Needs method="post" and enctype="multipart/form-data" on the form. |
hidden | Extra info people don't fill in | Not secret: it's in the page source. |
Need just one field with its own look? The HTML Text Box Generator and the HTML Dropdown Generator make a single input, textarea, dropdown, checkbox group or radio group with every style option.
Every field needs a <label> whose for matches the field's id. Screen
readers read it out, and clicking the label puts the cursor in the field, which is a much bigger target on a phone. A
placeholder isn't a label: it disappears as soon as you type.
The code:
<form>
<label for="phone">Phone number</label>
<input type="tel" id="phone" name="phone"
autocomplete="tel" aria-describedby="phone-help">
<p id="phone-help">Include your country code, like +44.</p>
<fieldset>
<legend>Best time to call</legend>
<input type="radio" id="am" name="time" value="am">
<label for="am">Morning</label>
<input type="radio" id="pm" name="time" value="pm">
<label for="pm">Afternoon</label>
</fieldset>
</form> You'll see:
required attribute (screen readers say “required”) and a visible *, with a note that explains it.
Browsers check a lot for free before a form is sent: required fields, the format of
type="email" and type="url", minlength and maxlength,
min and max on numbers and dates, and pattern, a regular expression the whole
answer must match. If something is wrong, the browser stops, jumps to the field and shows a message.
The code:
<style>
input:user-invalid {
border: 2px solid #b91c1c;
}
</style>
<form>
<label for="zip">ZIP code</label>
<input id="zip" name="zip" required
pattern="[0-9]{5}" inputmode="numeric">
<label for="age">Age</label>
<input type="number" id="age" name="age" min="18" max="120">
</form> You'll see (type “12” as the ZIP code, then click the age box):
:user-invalid styles a field only after someone has changed it and moved on, so an empty form doesn't
start out covered in red. The honest part: all of this runs in the visitor's browser, and anyone can switch it off
or send answers without your page at all. Treat it as help for real people, and always check the answers
again on your server.
A few rules do most of the work: box-sizing: border-box and width: 100% so fields fill
their space without spilling over, font: inherit so fields use your page's font (they don't by
default), padding for a comfortable click target, and a clear :focus style. For two fields side by side,
a wrapping flex row is enough. They share a line on a wide screen and stack on a phone, without a media query.
The code:
<style>
.form {
display: flex;
flex-wrap: wrap;
gap: 14px 16px;
max-width: 480px;
}
.form > * {
flex: 1 1 100%;
}
.form > .half {
flex: 1 1 calc(50% - 8px);
min-width: min(100%, 13rem);
}
.form label {
display: block;
margin-bottom: 4px;
font-weight: 600;
}
.form input {
box-sizing: border-box;
width: 100%;
padding: 9px 11px;
font: inherit;
border: 1px solid #6b7280;
border-radius: 6px;
}
.form input:focus {
outline: 2px solid transparent;
border-color: #4f46e5;
box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.3);
}
</style>
<form class="form">
<div class="half">
<label for="first">First name</label>
<input id="first" name="first-name" autocomplete="given-name">
</div>
<div class="half">
<label for="last">Last name</label>
<input id="last" name="last-name" autocomplete="family-name">
</div>
</form> You'll see (make the window narrow and they stack):
Keep text at 16px or more in form fields, or iPhones zoom the page in when you tap one. For the button itself, try the HTML Button Generator.
This is the part that surprises people: HTML can't send email or save answers by itself. The form
hands the answers to the address in action, and something there has to receive them. You have two
choices:
name, checks it, and saves it or emails it to you.action and email you every answer, often with spam filtering. Check what they do with the data before you pick one.Here's roughly what a small PHP script for the contact form looks like:
<?php
// contact.php: the page your form's action points to.
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$message = trim($_POST['message'] ?? '');
$trap = $_POST['website'] ?? ''; // the honeypot
if ($trap !== '') { exit; } // a bot filled it in
if ($name === '' || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
http_response_code(400);
exit('Please go back and fill in your name and a valid email.');
}
// Save it or email it to yourself here, then say thanks.
echo 'Thanks, we got your message!';
And action="mailto:[email protected]"? It only opens the visitor's own mail app with the answers pasted
in, if they have one set up. Many people don't, so it's not a reliable way to get messages.
Public forms get spam within days. A simple first step is a honeypot: an extra text field moved off screen and taken out of the Tab order, labelled “Leave this field empty”. People never see it, but many simple bots fill in every field they find. Your server then ignores any answer where the trap isn't empty. Switch on Spam trap in the form settings to add one.
enctype="multipart/form-data" and POST, only the file name is sent.tel or text with inputmode="numeric".When your form is on a page, run it through the HTML Validator to catch duplicate ids and missing labels, or try the whole page in the HTML Editor.
Put your fields inside a form element: a label and an input for the name, an input type="email" for the email, a textarea for the message and a button type="submit". Give every field a name, because the name is what the answer is called when the form is sent. Then set action to the address that receives the answers. The Contact form template in this builder writes all of that for you.
No. HTML can show the form and collect the answers, but something has to receive them: a script on your server (PHP, Node, Python and so on) or a form service that gives you an address to put in action and emails you the answers. An action like mailto:[email protected] only opens the visitor's own mail app, if they have one set up, so it's not a reliable way to get messages.
action is the address the answers are sent to, like /contact or https://example.com/subscribe. Leave it out and the form sends to the page it is on. method says how: POST sends the answers in the body of the request, which is right for anything private and needed for file uploads. GET adds them to the address as ?name=value, which is handy for search and filter forms you might want to bookmark.
The usual reason is a missing name attribute: a field without a name is never sent, even if it has an id. Other reasons: the field is disabled, it sits outside the form element (and has no form attribute), or it's a checkbox that isn't ticked. Unticked checkboxes send nothing at all, so treat a missing checkbox as no on your server.
Add the required attribute: <input type="email" name="email" required>. The browser then won't send the form until the field is filled in, and for type="email" it also checks that it looks like an email address. For a dropdown, add a first option with value="" (like "Choose…") or required has nothing to check. These checks help people fix mistakes, but anyone can get around them, so check the answers on your server too.
Make the form a flex container that wraps (display: flex; flex-wrap: wrap; gap: 16px) and give the two fields flex: 1 1 calc(50% - 8px) with a min-width like 13rem. They share a row on a wide screen and stack on a phone, with no media query. In this builder, tick Half width on two fields in a row.
Use <input type="file" name="resume"> and set two things on the form: method="post" and enctype="multipart/form-data". Without them, only the file name is sent, not the file. The accept attribute (accept=".pdf,.doc,.docx") filters the file picker, and multiple lets people choose more than one file. Your server still has to check the type and size of what arrives.
A simple first step is a honeypot: an extra text field that's moved off screen and taken out of the Tab order, with a label like "Leave this field empty". People never see it, but many simple bots fill in every field, so your server can throw away any answer where it isn't empty. Switch on Spam trap in the builder to add one. It won't stop every bot; rate limits or a captcha on the server can help with the rest.
Yes, it's free and there's no sign-up. Everything runs in your browser: your last form is kept in this browser's local storage so it's there when you come back, and nothing is sent to us. The preview never sends your test answers anywhere either.