splitforms.com

HTML · INPUT TYPE

HTML input type search: search boxes and GET forms

An <input type="search"> is a text field meant for search queries. Most browsers add a clear (x) button, and phones can show a search key on the keyboard. Put it in a form with method="GET" and the query is sent in the URL, such as /search?q=red+shoes.

  • 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

search-input-example.html
<form role="search" action="/search" method="GET"><input type="search" name="q" aria-label="Search"></form>

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 Input Type Search 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.

input-type-search.html
<!-- A GET site search: the query goes to your own /search page in the URL.
     No access_key here, because this is not a form backend submission. -->
<form role="search" action="/search" method="GET">
  <label for="site-search">Search the site</label>
  <input type="search" id="site-search" name="q"
         enterkeyhint="search" autocomplete="off"
         placeholder="e.g. contact form">

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

Attributes · <input type="search">

Which HTML Input Type Search attributes matter?

These attributes decide how the <input type="search"> behaves and what actually gets emailed to your inbox when someone submits.

HTML Input Type Search attributes and what each one does
AttributeWhat it doesDocs
nameThe key the query is sent under. q is the usual name, so the URL ends in ?q=.... Without a name, nothing is sent.
enterkeyhintUse search so mobile keyboards label the Enter key as Search.MDN
placeholderAn example query, like e.g. contact form. It disappears on typing, so it is not a label.MDN
minlength / maxlengthThe fewest and most characters allowed. minlength only checks a field that isn't empty.MDN
listThe id of a <datalist> whose options show as suggestions. Visitors can still type anything.
spellcheckSet spellcheck="false" to stop red underlines on product names and codes.MDN

Common mistakes

HTML Input Type Search not working? Here's why.

Most broken forms come down to a few small mistakes with the <input type="search">. Check these before you ship, then forward every submission to Slack or a webhook.

  1. It works like a text input

    type=search has no validation beyond a text input. Any text passes, so minlength, maxlength and pattern are the only checks you get.

  2. The clear (x) button looks different in each browser

    Chrome, Safari and Edge draw their own clear button, and Firefox may not show one. In WebKit and Blink browsers you can style or hide it with ::-webkit-search-cancel-button.

  3. Mark the form as a search landmark

    Put role="search" on the <form>, or wrap it in the <search> element, so screen reader users can jump straight to it.

  4. GET puts the query in the URL

    With method="GET" the query shows up in the address bar, browser history and server logs. Don't use a GET search form for private data.

  5. Spaces become + in the query string

    The form encodes the query, so red shoes arrives as ?q=red+shoes. Your server decodes it back to a space.

Sources: WHATWG HTML Standard: search state (type=search) · MDN: <input type="search">

Key benefits

Copy-paste ready

The HTML Input Type Search 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 input type search 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 <input type="search"> form actually sends data to a free splitforms backend, with spam filtering built in.

How it works

How to add HTML Input Type Search to any page.

Copy the html input type search 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 Input Type Search 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 Input Type Search questions, answered.

Anything missing? Email us, we read every message.

A person reading answers to common questions
What is the difference between input type search and type text?

Both accept any text. type=search tells the browser the field is for searching, so most browsers add a clear (x) button, phones can show a search key, and some browsers style it as a search box.

How do I remove the clear button from a search input?

In Chrome, Safari and Edge, hide it with CSS: input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }. Firefox does not add one by default.

How does the search query reach the backend?

In a form with method="GET", the browser adds the field's name and value to the action URL, so a field named q with the text red shoes sends /search?q=red+shoes. Your server reads the q parameter from the query string.

How do I submit a search input when the user presses Enter?

Put it inside a <form>. Pressing Enter in the field already submits the form, so no JavaScript is needed. Add enterkeyhint="search" so mobile keyboards label the key Search.

How do I add suggestions to a search input?

Add a <datalist> with an id and some <option> values, then set list to that id on the input. The browser shows matching options as suggestions, and visitors can still type anything.

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