splitforms.com

HTML · INPUT ATTRIBUTE

HTML placeholder attribute: examples, styling and accessibility

The placeholder attribute shows a short hint inside an empty text-like <input> or <textarea>. It disappears as soon as the visitor types, it is not sent with the form, and it doesn't replace a visible label.

  • Live, editable example
  • Copy-paste snippet
  • Attributes & common mistakes
Live demo · nothing is sent

What gets submitted

Fill in the form above and press its button. The demo stops the request and lists every name=value pair the browser would send, plus the controls it leaves out.

With a free access key in the form, these fields land in your splitforms dashboard; access_key and botcheck are read by splitforms, not stored as lead data.

Edit the HTML and re-run it
Runs in a sandbox. Nothing is sent.

Minimal snippet

placeholder-example.html
<input type="email" name="email" placeholder="you@example.com">

Want this form to email you its submissions? Point it at a free splitforms endpoint, with no server to build. Get a free access key →

Copy-paste code

HTML Placeholder Attribute code you can paste today.

Replace YOUR_ACCESS_KEY with a key from your free splitforms dashboard. The form posts to one endpoint — submissions land in your inbox and dashboard with spam filtering built in.

placeholder.html
<form action="https://splitforms.com/api/submit" method="POST">
  <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY">

  <label for="name">Name</label>
  <input type="text" id="name" name="name" placeholder="Jane Doe" autocomplete="name" required>

  <label for="email">Email</label>
  <input type="email" id="email" name="email" placeholder="you@example.com" autocomplete="email" required>

  <label for="message">Message</label>
  <textarea id="message" name="message" rows="5" placeholder="How can we help?" required></textarea>

  <!-- Honeypot: hidden from people, bots fill it in -->
  <input type="checkbox" name="botcheck" style="display:none" tabindex="-1" autocomplete="off">

  <button type="submit">Send</button>
</form>

<style>
  ::placeholder {
    color: #6b7280;
    opacity: 1; /* Firefox lowers placeholder opacity by default */
  }
</style>

Key facts

How does placeholder behave?

placeholder is a hint for empty text-like fields. It is never submitted, it is styled with ::placeholder, and it is not a reliable accessible name.

How does placeholder behave?
FactDetail
Where it worksOn <input> types text, search, url, tel, email, password and number, and on <textarea>. It is ignored on checkbox, radio, file and date inputs and on <select>.
Not submittedThe placeholder is never sent. An untouched field sends an empty value, so required still fails.
Line breaksAllowed in a <textarea> placeholder, but not in an <input> placeholder.
StylingUse the ::placeholder pseudo-element. Firefox lowers its opacity by default, so set opacity: 1 to get the exact color.
:placeholder-shownThis CSS pseudo-class matches a field while its placeholder is visible, which is handy for floating-label effects.
AccessibilityIt is not a reliable accessible name. Screen readers handle it inconsistently, so every field still needs a <label>.

Sources: WHATWG HTML Standard: the placeholder attribute · MDN: input placeholder

Attributes · placeholder

Which attributes and CSS go with placeholder?

The attribute sets the hint text. These CSS selectors style it, and aria-describedby gives help text that doesn't disappear.

HTML Placeholder Attribute attributes and what each one does
AttributeWhat it does
placeholderThe hint text shown while the field is empty, like you@example.com. Keep it short and use it as an example, not as instructions.
::placeholderA CSS pseudo-element that styles the placeholder text, for example its color and font style.
:placeholder-shownA CSS pseudo-class that matches the field itself while the placeholder is visible, so you can style empty fields differently.
aria-describedbyThe accessible way to give lasting help text. Point it at the id of a visible hint, such as a format rule, that stays on screen while the visitor types.

Common mistakes

placeholder mistakes to avoid

Most placeholder problems come from asking it to do a label's or a default value's job.

  1. A placeholder is not a label

    The hint vanishes as soon as the visitor types, so they forget what the field was for, and screen readers announce placeholders inconsistently. Give every field a visible <label>.

  2. A placeholder is not a default value

    Placeholder text is never submitted. If the field should start with a real value that gets sent, use the value attribute instead.

  3. Light grey text fails contrast

    Very pale placeholder text fails the WCAG contrast check and is hard to read. Pick a darker grey such as #6b7280 on white and set opacity: 1.

  4. Don't hide format rules in the placeholder

    Rules like "8+ characters" or "DD/MM/YYYY" disappear on the first keystroke. Put them in visible help text linked with aria-describedby.

Sources: WHATWG HTML Standard: the placeholder attribute · MDN: input placeholder

Key benefits

Copy-paste ready

The HTML Placeholder Attribute example below is a complete, working form — paste it into any HTML page and it submits, no edits to the markup required.

No backend to build

Your html placeholder attribute form posts to one endpoint. No server, PHP, or API route — accepted submissions are saved to your dashboard before owner notification email is attempted; delivery time and inbox placement depend on provider and recipient settings.

A form that really submits

Unlike a static reference snippet, this placeholder form actually sends data to a free splitforms backend, with spam filtering built in.

How it works

How to add HTML Placeholder Attribute to any page.

Copy the html placeholder attribute example, drop in your free access key, and paste it into any page — submissions start landing in your dashboard.

  1. Copy the code

    Copy the HTML Placeholder Attribute example below.

  2. Add your access key

    Replace YOUR_ACCESS_KEY with a free splitforms key from the dashboard.

  3. Paste into your site

    Drop the form into any HTML page. Submissions arrive in your dashboard.

Questions

HTML Placeholder Attribute questions, answered.

Anything missing? Email us, we read every message.

A person reading answers to common questions
Is placeholder text submitted with the form?

No. The placeholder is only a visual hint. If the visitor leaves the field untouched, the form sends an empty value for it, and a required field fails validation.

How do I change the placeholder color in CSS?

Use the ::placeholder pseudo-element, for example input::placeholder { color: #6b7280; opacity: 1; }. Firefox lowers placeholder opacity by default, so opacity: 1 makes the color match in every browser.

Can a placeholder replace a label?

No. The placeholder disappears as soon as the visitor starts typing, and screen readers don't handle it reliably as the field's name. Use a visible <label> and keep the placeholder as an optional example.

Does placeholder work on a select element?

No. <select> ignores the placeholder attribute. Instead, make the first <option> disabled and selected with an empty value, like <option value="" disabled selected>Choose one</option>. The HTML select page shows the full pattern.

View all FAQs

Make this form actually submit.

Point your form at splitforms. 500 free submissions a month, spam filtering, webhooks on paid plans — no server.

  • No credit card required
  • 500 free submissions
  • Setup in minutes
Two people celebrating a working contact form