Blog
Evgenii Zakharov Development Team
Blog
Nov 30, 2026
3
0

How to Create a Simple HTML Form: Code and Email Delivery

You paste a basic HTML form onto your page, type a quick test message, and click "Send". Then the browser shows a 404 screen, or the page just reloads and nothing ever reaches your inbox.

Writing the tags takes five minutes. Getting those answers into your email without inviting a flood of bot spam is the half most tutorials leave out.

Notice image
Short answer. A working web form needs three parts: a form tag with action and method="POST", labeled fields that each carry a name, and a real destination to catch submissions. HTML draws the fields on screen; a server script, a hosted endpoint, or an embedded form builder delivers the replies.

Build a basic contact form step by step

Start with three fields: full name, email address, and message. Skip br tags for spacing and let clean HTML5 structure do the work.

  1. Open form with a real destination. Add action="YOUR_ENDPOINT_URL" and method="POST" so the browser knows where and how to send what a visitor types.
  2. Pair every label for with a matching id. Clicking the label jumps straight into the box on desktop and mobile, and screen readers announce each field clearly.
  3. Give every field a unique name. If an input has no name attribute, the browser quietly leaves it out when sending the message.
  4. Use specific input types and autocomplete. Setting type="email" opens the "@" keyboard on phones and checks the email format before sending.
  5. Finish with button type="submit". Visitors can tap the button or press Enter to send their note.
  6. Complete contact form HTML

    <form class="contact-box" action="https://example.com/contact" method="POST">
      <label for="full-name">Full name</label>
      <input id="full-name" name="full_name" type="text" autocomplete="name" required>
    
      <label for="reply-email">Email address</label>
      <input id="reply-email" name="email" type="email" autocomplete="email" required>
    
      <label for="user-message">Message</label>
      <textarea id="user-message" name="message" rows="5" required></textarea>
    
      <button type="submit">Send message</button>
    </form>

    Replace "https://example.com/contact" with your real server route or form backend URL before publishing. Also notice one tag detail: input stands on its own without a closing tag, while textarea always needs a closing /textarea.

    Five key attributes on the form tag

    Before you add more fields, get familiar with the five attributes on the opening form tag. They tell the browser where answers go and how to package them.

    Attribute What it does
    action Sets the destination URL, such as a server script or hosted endpoint, that receives submitted answers.
    method Picks how data travels. "POST" sends values inside the request body; "GET" tacks them onto the page URL.
    enctype Sets the encoding format. Use "multipart/form-data" whenever visitors upload files.
    autocomplete Lets browsers fill in saved names, emails, and addresses. It stays on by default.
    novalidate Turns off default browser error popups if you prefer to write your own validation checks.

    Core HTML form elements and when to use each

    Most contact, feedback, signup, and order pages come down to six elements. Pick the tag that fits the answer instead of dropping plain text boxes everywhere.

    Element Where it fits best
    input One-line answers like names, emails, phone numbers, or passwords, paired with matching autocomplete.
    textarea Longer comments or project notes. Set rows="5" and close the tag with /textarea.
    Checkbox Consent toggles or multi-select questions using type="checkbox". Wrap groups inside fieldset.
    Radio button One choice from a short list using type="radio". Give every option in the group the same name.
    select A dropdown menu with option items for long lists like countries or support topics.
    Hidden field Passes extra values like a page ID or security token via type="hidden". Never store secrets here, because anyone can view source.

    Textarea, checkboxes, and short survey code

    Multi-line messages belong in an HTML form textarea. Giving it rows="5" lets visitors read their whole reply at once, and adding maxlength="1000" keeps long notes from running away.

    Use HTML checkboxes for consent toggles or questions where visitors can pick more than one option. Wrap grouped checkboxes and radio buttons in fieldset with a legend heading so assistive tools read the question first.

    <form class="contact-box" action="https://example.com/survey" method="POST">
      <input type="hidden" name="page_source" value="homepage">
    
      <fieldset>
        <legend>How easy was checkout?</legend>
        <label><input type="radio" name="ease" value="easy" required> Easy</label>
        <label><input type="radio" name="ease" value="okay"> Okay</label>
        <label><input type="radio" name="ease" value="hard"> Hard</label>
      </fieldset>
    
      <fieldset>
        <legend>Which topics interest you?</legend>
        <!-- topics[] collects multiple checked boxes into a list -->
        <label><input type="checkbox" name="topics[]" value="guides"> Guides</label>
        <label><input type="checkbox" name="topics[]" value="updates"> Product updates</label>
      </fieldset>
    
      <label for="role">Your role</label>
      <select id="role" name="role" required>
        <option value="">Choose one</option>
        <option value="owner">Site owner</option>
        <option value="dev">Developer</option>
        <option value="marketing">Marketer</option>
      </select>
    
      <button type="submit">Send answers</button>
    </form>

    File upload and registration variants

    Adding a file upload input takes one extra attribute on the opening form tag. Pair enctype="multipart/form-data" with method="POST", or the browser sends only the filename text and leaves the actual file behind.

    For a signup or login form template, pair type="password" with minlength="8" and autocomplete="new-password". On a sign-in page, switch that value to "current-password" so password managers fill credentials cleanly.

    <!-- File upload with enctype -->
    <form class="contact-box" action="https://example.com/upload" method="POST" enctype="multipart/form-data">
      <label for="project-brief">Upload PDF or image</label>
      <input id="project-brief" name="brief" type="file" accept=".pdf,.png,.jpg" required>
      <button type="submit">Upload file</button>
    </form>
    
    <!-- Simple registration -->
    <form class="contact-box" action="https://example.com/signup" method="POST">
      <label for="reg-email">Work email</label>
      <input id="reg-email" name="email" type="email" autocomplete="email" required>
    
      <label for="reg-pass">Password</label>
      <input id="reg-pass" name="password" type="password" minlength="8" autocomplete="new-password" required>
    
      <button type="submit">Create account</button>
    </form>

    Submit button: button vs input type="submit"

    Choose button type="submit" instead of input type="submit" value="Send". Both send the answers, while button lets you add icons or styled text inside and fits right into modern CSS button styles.

    Add clean CSS and dark mode styles

    Plain browser fields look cramped on phones. About twenty lines of scoped CSS give you full-width stacking, comfortable tap areas, clear keyboard focus outlines, and automatic dark mode styling that follows the visitor's system theme.

    .contact-box {
      display: grid;
      gap: 0.75rem;
      max-width: 28rem;
      font-family: system-ui, sans-serif;
    }
    .contact-box label {
      font-weight: 600;
    }
    .contact-box input:not([type="checkbox"]):not([type="radio"]),
    .contact-box textarea,
    .contact-box select {
      box-sizing: border-box;
      width: 100%;
      padding: 0.65rem 0.75rem;
      border: 1px solid #cbd5e1;
      border-radius: 6px;
      font: inherit;
    }
    .contact-box button[type="submit"] {
      padding: 0.75rem 1.25rem;
      border: 0;
      border-radius: 6px;
      background: #111827;
      color: #ffffff;
      font-weight: 600;
      cursor: pointer;
    }
    .contact-box :focus-visible {
      outline: 2px solid #2563eb;
      outline-offset: 2px;
    }
    @media (prefers-color-scheme: dark) {
      .contact-box input:not([type="checkbox"]):not([type="radio"]),
      .contact-box textarea,
      .contact-box select {
        background: #1e293b;
        color: #f8fafc;
        border-color: #475569;
      }
    }

    If your site already uses a CSS framework, skip custom rules. Adding class="form-control" and class="form-select" turns plain HTML inputs and dropdowns into styled Bootstrap form controls right away.

    Four silent bugs that break beginner code

    Browsers will not warn you when one of these attributes goes missing. The page looks finished, a visitor clicks "Send", and half the data disappears or leaks into browser history.

    • Only id, no name
      Bad: input id="mail" type="email" sends nothing at all.
      Better: Include both id="mail" and name="email", matching the rule in the W3Schools form guide.
    • Using GET for private details
      Bad: method="GET" puts names and messages straight into the page URL, where they sit in browser history and server logs.
      Better: Use method="POST" so personal details travel inside the request body.
    • Placeholders instead of labels
      Bad: input placeholder="Email" vanishes the second someone types and leaves screen readers guessing.
      Better: Pair a visible label for="mail" with id="mail", following the semantics in the MDN first form guide.
    • File picker without enctype
      Bad: input type="file" with default encoding sends only the filename text.
      Better: Add enctype="multipart/form-data" so the browser sends the real file bytes.

    What happens when a visitor clicks Submit

    Knowing what the browser does behind the scenes makes troubleshooting much faster. One click kicks off four quick steps:

    • The browser runs built-in checks. It verifies required, minlength, and type="email", pausing if anything is missing or mistyped.
    • It gathers every named field. Each control with a name adds its name=value pair, while unnamed fields get skipped.
    • It packs and sends the request. The browser sends an HTTP POST request to your action URL using the encoding you chose.
    • Your destination replies. A server script or hosted handler saves the entry, emails your inbox, and shows a thank-you page.

    Want the page to submit without reloading, or show custom inline messages as visitors type? Add that layer separately in JavaScript with FormData and fetch once your plain HTML works.

    How to send submissions to your email inbox

    Plain HTML cannot email you by itself. Web browsers have no built-in mail server, so leaving action empty just refreshes the page and throws away everything the visitor wrote.

    Notice image
    Skip action="mailto:[email protected]". It relies on a local desktop mail app, fails silently for most Gmail and phone visitors, mangles the message text, and leaves your email address exposed in raw HTML for spam scrapers.

    To route an HTML form to email reliably, point your code at one of three real destinations.

    • PHP or server script
      Setup: Write a handler with authenticated SMTP, such as PHPMailer.
      Best fit: Sites already running a custom server.
    • Hosted endpoint
      Setup: Paste the endpoint URL into action.
      Best fit: Static pages that only need simple inbox mail.
    • Embedded builder
      Setup: Build visually and paste one embed snippet.
      Best fit: Teams needing alerts, file uploads, or surveys.

    Option 1: PHP or your own server

    If your host runs PHP, Node, or Python, set action="/contact.php" and read submitted fields on the server. Skip raw PHP mail, which inbox providers often reject or flag as spam, and send through authenticated SMTP with valid SPF and DKIM records on your domain.

    Option 2: Hosted endpoint without PHP

    Static hosts like GitHub Pages or Netlify do not run PHP. Keep your exact contact HTML, point the action attribute at a hosted endpoint service, and let it forward every reply straight to your inbox.

    Option 3: Embedded no-code builder

    Once a simple contact box grows into a multi-step signup, file intake, or short questionnaire, writing your own backend stops being worth the time. An online form builder handles design, email alerts, and storage with no server upkeep.

    Stopping spam bots and where a honeypot falls short

    Public contact pages attract automated bots within days of launch. A light first filter is a honeypot: an extra text box tucked off-screen with CSS that real visitors never see while basic scripts fill every input on the page.

    <div class="hp-wrap" aria-hidden="true">
      <label for="company-url">Leave this blank</label>
      <input id="company-url" name="company_url" type="text" tabindex="-1" autocomplete="off">
    </div>

    Move .hp-wrap off-screen in CSS using position: absolute and left: -9999px. On your server, quietly ignore any submission where company_url has text in it.

    Notice image
    Honest limit. A honeypot catches simple scripts, not headless browsers or targeted spam bursts. Any live self-hosted contact page still needs server-side rate limits, input validation, or a challenge check so bots do not burn through your mail quota.

    Quick pre-launch check for hand-coded pages

    • Try it on a phone. Tap the email box and make sure the "@" keyboard pops up cleanly.
    • Submit empty fields. Check that browser required messages appear without breaking your layout.
    • Watch the Network tab. Open DevTools, send a test entry, and confirm every name=value pair shows up in the POST body.
    • Check both inbox and spam. Send yourself a real test note and confirm it lands in your main inbox instead of junk.

    When to code by hand vs embed with Pollsar

    Hand-code your markup when you already run a backend, need tight hooks into a custom web app, or just want a three-field contact box on a static portfolio.

    Move to a hosted form generator once a project asks for branching rules, file uploads, multi-page flows, or response charts. You can skip the backend plumbing with Pollsar for websites.

    • Four embed formats. Place your project as an inline frame, a pop-up modal, a slide-out tab, or a full page, plus a direct link and QR code inside Pollsar distribution tools.
    • Inbox alerts and webhooks. Route entries to webhooks, Zapier, Slack, Telegram, or Google Sheets, and alert yourself, teammates, or visitors with Pollsar email notifications.
    • Ready-made inputs and themes. Combine text, email, rating, choice, NPS, and file upload fields across 80 matched themes without writing CSS, using the Pollsar question types library.
    • Instant charts and exports. Read single replies or summary tables in one workspace, then export CSV, XLSX, JSON, or PDF files without running a database.

    Decision rule

    Code a three-field contact box by hand if you already maintain a server. Embed a ready-made builder the moment you need conditional paths, file uploads, or instant reporting.

    Frequently asked questions

    Plain HTML cannot email Gmail on its own. Point the action attribute at a hosted endpoint service that forwards entries to your Gmail inbox, or embed a hosted builder with built-in email alerts.
    GET appends answers to the page URL, which works well for search bars that visitors might bookmark. POST sends entries inside the HTTP request body, keeping personal details out of browser history and server logs.
    Check that every input, textarea, and select has a name attribute. Browsers skip fields that only have an id when building the outgoing request.
    Pure HTML renders one flat page at a time. Multi-step progress bars and conditional next screens call for JavaScript in the browser, separate server pages, or a builder with built-in page navigation and logic.
    Add method="POST" and enctype="multipart/form-data" to the opening form tag, then place input type="file" name="attachment" accept=".pdf,.png,.jpg" inside. Always verify the file size and file type on your server before saving anything.
    The form tag is a container that groups inputs like text boxes, checkboxes, and buttons, then tells the browser where to send the values through action and how to send them through method.

    Put a working form live without touching PHP

    Copy the HTML5 snippets above whenever you want lean markup on your own server. When you want a styled contact box, signup flow, or site survey live in minutes with inbox alerts and exports, describe your goal and start free with Pollsar.

Recommended
Anastasia Antropova Marketing Team
Blog
Customer Review Template: Form, Scripts, and FTC Rules
Long feedback forms sit half-finished, and outdated funnel tricks put your profile at risk. Use this five-question template, short request scripts, and clean FTC rules to gather honest reviews.
Nov 30, 2026
6
0
Eugene Yasnikov Product Team
Blog
How Do I Fill Out a W-9? A Line-by-Line Guide
One wrong box on a W-9 can stall a payout and trigger 24% IRS backup withholding. Check whether you need a W-9 first, match your tax setup to Lines 1 through 3b, and send page 1 back safely.
Nov 30, 2026
4
0
Anastasia Antropova Marketing Team
Blog
Market Segmentation: Pick a Base, Test Groups, Build Offers
You slice your list by age and job title, yet every buyer gets the same pitch. Pick a segmentation base from your decision, test groups with five checks, and turn one survey into three offers.
Nov 30, 2026
4
0
Eugene Yasnikov Product Team
Blog
CSAT Score: Formula, Benchmarks, Scale Rules, and DSAT
An 84% dashboard can hide rising churn when easy tickets drown out broken flows. Use the exact CSAT formula, track dissatisfied replies beside it, and catch real friction before accounts leave.
Nov 30, 2026
3
0
Anastasia Antropova Marketing Team
Blog
Good Questions to Ask Your Friends: 75 Ideas by Mood
Hangouts stall on work updates, and random lists feel like a job interview. Pick from 75 clean questions sorted by mood, keep talk natural with two follow-ups, or share a quick quiz.
Nov 29, 2026
3
0
Evgenii Zakharov Development Team
Blog
Eisenhower Matrix Template: Grid, Rules, and HR Example
Every message arrives marked urgent while real work waits. Use this Eisenhower matrix template, two plain rules, and a short team intake form to sort Monday in ten minutes.
Nov 29, 2026
4
0
Eugene Yasnikov Product Team
Blog
Multiple Answer Questions: Examples, Rules, and Analysis
Checkbox totals pass 100%, blank rows hide skips, and respondents miss half the list. Choose the right format, copy clean wording, and read multi-select percentages with confidence.
Nov 29, 2026
3
0
Anastasia Antropova Marketing Team
Blog
Truth or Dare Questions: 70 Clean Ideas and Rules
Most truth or dare lists jump from boring trivia to awkward phone dares, so rounds stall fast. Pick from 70 clean ideas across three comfort levels, with easy rules and a remote setup.
Nov 29, 2026
0
0