Format Code Now
/
Web & markupHTML Search Input Generator Next: HTML Strong Text Generator ›

HTML Search Input Generator

WM-61

Describe the search box and get an input of type search with a label, a submit button and a search landmark around it.

Runs in your browser. Nothing is uploaded.

Attribute lines: label:, name:, id:, value:, placeholder:, maxlength:, hint:, action:, button:

HTML

How to use it

  1. Write label:, name: and action: lines, plus optional placeholder:, value:, maxlength:, hint: and button:.
  2. Choose the wrapper: a form with role=search, a search element, or the input only.
  3. Pick the form method (get is usual for search) and the label style.
  4. Copy the HTML into your page.

The search landmark

Screen reader users can jump straight to a page's search area when it is marked as a landmark. There are two ways: add role="search" to the form, or wrap the form in the search element, which has the same role built in. The tool writes either one. If a page has more than one search area, give each its own label so users can tell them apart, for example with aria-label. The landmark goes around the whole form, not just the input.

What type=search changes

An input of type search holds text like a text input and submits like one. The type is a hint to the browser: some draw a clear button inside the field once you type, and phone keyboards may show a search key. It does not search anything by itself, and it does not run a request until the form is submitted. A line break pasted into the field is removed. The label, and not the placeholder, is the field's name, so the tool requires a label line.

Get versus post

Search forms normally use method get, so the query appears in the address, can be bookmarked and shared, and works with the back button. The tool defaults to get here. Post is available for cases such as queries that should not appear in logs or history. The action is the page that handles the search; an address beginning with javascript: is refused. The button text defaults to Search and can be changed with a button line.

Error messages and what to do

MessageWhat it meansFix
Missing label. Add a line such as "label: Email address"; every input needs a visible label.The input has no label: line.Add label: and the text users should see.

Questions people ask

How do I add a search box to a web page in HTML?

Use a form with an input of type search and a submit button, with the form's action pointing to your search page. This tool writes that markup with a label.

What is role="search" for?

It marks the form as a search landmark so screen reader users can find it quickly. The search element has the same meaning built in.

What is the difference between type=search and type=text?

They behave almost the same. type=search tells the browser it is a search field, which can bring a clear button or a search key on a phone keyboard.

Should the search form use get or post?

Use get for most searches. The query then appears in the URL, which makes results shareable and works with the back button. Use post only when the query should stay out of the address bar, server logs and browser history, such as a sensitive lookup.

Do I still need a label if there is a placeholder?

Yes. A placeholder vanishes when typing and is not a dependable name. The label stays visible and is announced by screen readers. If your design hides the label, hide it visually while keeping it in the page, or use aria-label on the input.

About this tool

Builds a label and an input of type search. The search wrapper choices produce a form with role="search", or a search element that contains a form; both mark the area as a search landmark for assistive technology. The default method is get, so the query shows in the address. Some browsers draw a clear button inside a search input and some use a search key on phone keyboards; otherwise it behaves like a text input. The placeholder does not replace the label. Use an aria-label or distinct wording when a page has more than one search form. Values are escaped.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.