The code
<form class="lf-form" action="/api/contact" method="POST">
<div class="field">
<label for="f-name">Your name *</label>
<input id="f-name" name="name" type="text" placeholder="Jane Doe" required />
</div>
<div class="field">
<label for="f-email">Email address *</label>
<input id="f-email" name="email" type="email" placeholder="you@example.com" autocomplete="email" required />
</div>
<div class="field">
<label for="f-subject">Subject *</label>
<input id="f-subject" name="subject" type="text" placeholder="How can we help?" required />
</div>
<div class="field">
<label for="f-message">Message *</label>
<textarea id="f-message" name="message" rows="5" placeholder="Tell us what's on your mind…" required></textarea>
</div>
<button type="submit">Send message</button>
</form>
<style>
.lf-form { max-width: 480px; margin: 0 auto; font-family: system-ui, sans-serif; }
.lf-form .field { margin-bottom: 1rem; }
.lf-form label, .lf-form legend { display: block; font-weight: 500; margin-bottom: 0.35rem; font-size: 0.9rem; }
.lf-form input, .lf-form select, .lf-form textarea {
width: 100%; padding: 0.65rem 0.75rem; font-size: 1rem;
border: 1px solid #d1d5db; border-radius: 0.5rem; background: #fff;
font-family: inherit;
}
.lf-form input:focus, .lf-form select:focus, .lf-form textarea:focus {
outline: 2px solid #2563eb; outline-offset: 1px; border-color: #2563eb;
}
.lf-form .checkbox, .lf-form .radio { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
.lf-form .checkbox input, .lf-form .radio input { width: auto; }
.lf-form button {
width: 100%; padding: 0.75rem 1rem; font-size: 1rem; font-weight: 600;
color: #fff; background: #2563eb; border: 0; border-radius: 0.5rem; cursor: pointer;
}
.lf-form button:hover { background: #1d4ed8; }
</style>Live preview
Rendered in a sandboxed iframe — exactly what you'll get when you paste the snippet.
More contact form HTML templates
Same accessible markup, different fields. Copy the one closest to what you need and edit from there.
Simple contact form (name, email, message)
The shortest version that still gets you a reply address. Use it on a personal site, portfolio or landing page.
<form class="lf-form" action="/api/contact" method="POST">
<div class="field">
<label for="f-name">Your name *</label>
<input id="f-name" name="name" type="text" placeholder="Jane Doe" required />
</div>
<div class="field">
<label for="f-email">Email address *</label>
<input id="f-email" name="email" type="email" placeholder="you@example.com" autocomplete="email" required />
</div>
<div class="field">
<label for="f-message">Message *</label>
<textarea id="f-message" name="message" rows="5" placeholder="How can we help?" required></textarea>
</div>
<button type="submit">Send message</button>
</form>
<style>
.lf-form { max-width: 480px; margin: 0 auto; font-family: system-ui, sans-serif; }
.lf-form .field { margin-bottom: 1rem; }
.lf-form label, .lf-form legend { display: block; font-weight: 500; margin-bottom: 0.35rem; font-size: 0.9rem; }
.lf-form input, .lf-form select, .lf-form textarea {
width: 100%; padding: 0.65rem 0.75rem; font-size: 1rem;
border: 1px solid #d1d5db; border-radius: 0.5rem; background: #fff;
font-family: inherit;
}
.lf-form input:focus, .lf-form select:focus, .lf-form textarea:focus {
outline: 2px solid #2563eb; outline-offset: 1px; border-color: #2563eb;
}
.lf-form .checkbox, .lf-form .radio { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
.lf-form .checkbox input, .lf-form .radio input { width: auto; }
.lf-form button {
width: 100%; padding: 0.75rem 1rem; font-size: 1rem; font-weight: 600;
color: #fff; background: #2563eb; border: 0; border-radius: 0.5rem; cursor: pointer;
}
.lf-form button:hover { background: #1d4ed8; }
</style>Business enquiry form (company, phone, topic)
For sales and service enquiries, where knowing the company and the topic lets you route the message to the right person.
<form class="lf-form" action="/api/contact" method="POST">
<div class="field">
<label for="f-name">Full name *</label>
<input id="f-name" name="name" type="text" placeholder="Jane Doe" required />
</div>
<div class="field">
<label for="f-email">Work email *</label>
<input id="f-email" name="email" type="email" placeholder="jane@company.com" autocomplete="email" required />
</div>
<div class="field">
<label for="f-company">Company *</label>
<input id="f-company" name="company" type="text" placeholder="Company name" required />
</div>
<div class="field">
<label for="f-phone">Phone</label>
<input id="f-phone" name="phone" type="tel" placeholder="+44 20 7946 0000" autocomplete="tel" />
</div>
<div class="field">
<label for="f-topic">What is this about? *</label>
<select id="f-topic" name="topic" required>
<option value="" disabled selected>Choose…</option>
<option value="Sales">Sales</option>
<option value="Support">Support</option>
<option value="Partnerships">Partnerships</option>
<option value="Something else">Something else</option>
</select>
</div>
<div class="field">
<label for="f-message">Message *</label>
<textarea id="f-message" name="message" rows="5" placeholder="Tell us what you need" required></textarea>
</div>
<button type="submit">Send enquiry</button>
</form>
<style>
.lf-form { max-width: 480px; margin: 0 auto; font-family: system-ui, sans-serif; }
.lf-form .field { margin-bottom: 1rem; }
.lf-form label, .lf-form legend { display: block; font-weight: 500; margin-bottom: 0.35rem; font-size: 0.9rem; }
.lf-form input, .lf-form select, .lf-form textarea {
width: 100%; padding: 0.65rem 0.75rem; font-size: 1rem;
border: 1px solid #d1d5db; border-radius: 0.5rem; background: #fff;
font-family: inherit;
}
.lf-form input:focus, .lf-form select:focus, .lf-form textarea:focus {
outline: 2px solid #2563eb; outline-offset: 1px; border-color: #2563eb;
}
.lf-form .checkbox, .lf-form .radio { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
.lf-form .checkbox input, .lf-form .radio input { width: auto; }
.lf-form button {
width: 100%; padding: 0.75rem 1rem; font-size: 1rem; font-weight: 600;
color: #fff; background: #2563eb; border: 0; border-radius: 0.5rem; cursor: pointer;
}
.lf-form button:hover { background: #1d4ed8; }
</style>Contact form with a consent checkbox
Adds a required checkbox so the visitor agrees to be contacted before the form can be sent.
<form class="lf-form" action="/api/contact" method="POST">
<div class="field">
<label for="f-name">Your name *</label>
<input id="f-name" name="name" type="text" placeholder="Jane Doe" required />
</div>
<div class="field">
<label for="f-email">Email address *</label>
<input id="f-email" name="email" type="email" placeholder="you@example.com" autocomplete="email" required />
</div>
<div class="field">
<label for="f-message">Message *</label>
<textarea id="f-message" name="message" rows="5" placeholder="How can we help?" required></textarea>
</div>
<label class="checkbox">
<input type="checkbox" name="consent" value="1" required />
<span>I agree to be contacted about this enquiry</span>
</label>
<button type="submit">Send message</button>
</form>
<style>
.lf-form { max-width: 480px; margin: 0 auto; font-family: system-ui, sans-serif; }
.lf-form .field { margin-bottom: 1rem; }
.lf-form label, .lf-form legend { display: block; font-weight: 500; margin-bottom: 0.35rem; font-size: 0.9rem; }
.lf-form input, .lf-form select, .lf-form textarea {
width: 100%; padding: 0.65rem 0.75rem; font-size: 1rem;
border: 1px solid #d1d5db; border-radius: 0.5rem; background: #fff;
font-family: inherit;
}
.lf-form input:focus, .lf-form select:focus, .lf-form textarea:focus {
outline: 2px solid #2563eb; outline-offset: 1px; border-color: #2563eb;
}
.lf-form .checkbox, .lf-form .radio { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
.lf-form .checkbox input, .lf-form .radio input { width: auto; }
.lf-form button {
width: 100%; padding: 0.75rem 1rem; font-size: 1rem; font-weight: 600;
color: #fff; background: #2563eb; border: 0; border-radius: 0.5rem; cursor: pointer;
}
.lf-form button:hover { background: #1d4ed8; }
</style>Need different fields? Build your own with the contact form HTML code generator.
After the enquiry arrives
A contact form starts the conversation; the reply finishes it. Many teams answer a new enquiry by offering a short call. If you'd like the person to pick a time themselves instead of trading emails, a scheduling tool such as LemCall appointment scheduling can sit in your follow-up email. Keep the form itself short — name, email, subject and message are enough to qualify most enquiries.
Frequently asked questions
How do I receive contact form submissions in my email?
You need a backend endpoint or a forwarding service. The fastest path: replace the form with a LemForms embed — submissions land in your inbox immediately, with spam filtering and reply-to set automatically.
How do I stop spam on a contact form?
Add a honeypot field (a hidden input that bots fill but humans don't), then drop submissions where it's populated. Pair with rate-limiting. LemForms ships hCaptcha and honeypot protection out of the box.
How do I add a file attachment to this contact form?
Add enctype="multipart/form-data" to the <form> and an <input type="file" name="attachment">. You'll also need server-side handling for the upload.
Skip the HTML — build this in 30 seconds
LemForms gives you the same form with a real backend: submissions dashboard, email notifications, conditional logic, file uploads, webhooks, and Stripe payments. No code.
Try LemForms freeRelated snippets
- Signup form HTML templateFree signup form HTML template — plain HTML/CSS and Tailwind versions, accessible labels, working validation. Copy, paste, ship.
- Login form HTML templateFree login form HTML template with accessible labels, remember-me checkbox, and forgot-password link. Plain HTML and Tailwind variants.
- Subscription form HTML templateEmail subscription form HTML template with plan selector, GDPR consent checkbox, and accessible labels. Copy-paste ready.
- Booking form HTML templateFree booking form HTML template with native date + time pickers, party size, and notes field. Plain HTML and Tailwind variants.
- Survey form HTML templateFree survey form HTML template with rating scale, multiple-choice, and open-ended fields. Accessible, mobile-friendly, copy-paste ready.
- Quiz form HTML templateFree quiz form HTML template with multiple-choice questions and a submit handler. Plain HTML and Tailwind versions, ready to copy.