Skip to content
Page·Free

Contact form (HTML + CSS)

A contact form in one HTML file: name, email, an optional topic and the message. Every field has a label, and a red border appears only after someone types in it or tries to send. Set the form's action to your endpoint. Dark mode follows the system.

Free to install.

If PocketCode is installed on your Android device, this opens the page in the app.

Preview

contact-form.html · 123 lines
<!--
  Contact form section in plain HTML and CSS, no JavaScript.
  Set the form's action to your own endpoint (it posts name, email, topic and message).
  Colours live in the CSS variables at the top; dark mode follows the system setting.
-->
<section class="contact" aria-labelledby="contact-title">
  <style>
    .contact {
      --bg: #ffffff;
      --fg: #1b1b1f;
      --muted: #55555f;
      --line: #7c7c88;
      --accent: #1f5fd1;
      --accent-fg: #ffffff;
      --error: #b3261e;
      box-sizing: border-box;
      max-width: 560px;
      margin: 0 auto;
      padding: 24px 16px;
      background: var(--bg);
      color: var(--fg);
      font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    }
    @media (prefers-color-scheme: dark) {
      .contact {
        --bg: #121216;
        --fg: #ececf1;
        --muted: #a8a8b3;
        --line: #7c7c88;
        --accent: #8ab4ff;
        --accent-fg: #0b1a33;
        --error: #ffb4ab;
      }
    }
    .contact *, .contact *::before, .contact *::after { box-sizing: inherit; }
    .contact h2 { margin: 0 0 4px; font-size: 1.5rem; line-height: 1.25; }
    .contact-intro { margin: 0 0 24px; color: var(--muted); }
    .contact-form { display: grid; gap: 20px; }
    .contact-field { display: grid; gap: 6px; }
    .contact label { font-weight: 600; }
    .contact-optional, .contact-hint { color: var(--muted); font-weight: 400; }
    .contact-hint { margin: 0; font-size: 0.875rem; }
    .contact input,
    .contact select,
    .contact textarea {
      width: 100%;
      min-height: 48px;
      padding: 10px 12px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--bg);
      color: var(--fg);
      font: inherit;
    }
    .contact textarea { min-height: 140px; resize: vertical; }
    .contact input:focus-visible,
    .contact select:focus-visible,
    .contact textarea:focus-visible,
    .contact button:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }
    /* Red border only after the person has typed or tried to send, not on page load. */
    .contact input:user-invalid,
    .contact textarea:user-invalid {
      border-color: var(--error);
      border-width: 2px;
    }
    .contact button {
      justify-self: start;
      min-height: 48px;
      padding: 12px 24px;
      border: 0;
      border-radius: 8px;
      background: var(--accent);
      color: var(--accent-fg);
      font: inherit;
      font-weight: 600;
      cursor: pointer;
    }

This preview is shortened. You get the full content when you install it.

Changes in 1.0.0

First version.

Related

404 page (HTML + CSS)FreePageA "page not found" page in one HTML file. Save it as 404.html on your static site. It links to your home page and to a page for reporting the broken link, and shows a back button when there is a previous page. Light or dark follows the system.Pricing section (HTML + Tailwind)FreePageThree pricing plans in plain HTML with Tailwind CSS 4 classes, with no React or JavaScript. The cards stack on phones and switch to dark colours with the system setting. Your project needs Tailwind to build the styles. Replace the example plans and prices with yours.Sign-up form (Vue)FreePageA sign-up form for Vue 3 as a single-file component in TypeScript, with name, email and password. When you leave a field, it says what is wrong, and screen readers announce the same message. It uses no libraries, and the colours come from CSS variables.Login screen (Compose)FreePageEmail and password screen in Material 3. It checks both fields when you tap Sign in, shows the error your server returns, and can add Forgot password and fingerprint buttons. You call BiometricPrompt yourself.Landing hero (Next.js + Tailwind)FreePageHero section for the Next.js App Router: a title, a subtitle and two links over a soft gradient. It uses dark colours when the system is in dark mode.Settings screen (Compose)FreePageMaterial 3 settings screen with switches, a theme choice and a text size slider. It holds no state: you pass a SettingsState in and get the changed copy back. Each row is one touch target of 56 dp or more that TalkBack reads as a switch or radio button.