Input Types
HTML input type="search"
Collect a search query; it does not implement searching by itself. The browser may show a clear button or search-oriented keyboard. Implement actual search in the application or server. Use only attributes applicable to this input state; the browser ignores or rejects unrelated constraints. Validate submitted data on the server.
Formal Syntax & Structure
html syntaxhtml
<input type="search">Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| type | literal search | Selects the search input state. |
| name | string | Provides an element-specific name: a form field key, radio group name, named frame, metadata key, slot name or other defined purpose. Its meaning depends on the element; it is not a unique DOM identifier. |
| disabled | boolean | Disables supported controls or elements. Disabled form controls are generally not focusable, validated or submitted. The exact effect depends on the element; disabled="false" still disables. |
| form | form element ID | Associates an eligible control with a form elsewhere in the same document, overriding an ancestor form where applicable. Does not automatically associate descendants of a fieldset. |
| value | element-dependent text or number | Default value or submitted value depending on type. A file input cannot be prefilled with a path. |
| autocomplete | ordered autofill tokens or on/off | Gives the browser the purpose of a form field or controls autofill. Use meaningful tokens such as email or current-password. A browser may still offer password-manager autofill even with off. |
| maxlength | non-negative integer | Limits text length in applicable inputs and textareas, measured in UTF-16 code units. It is not a byte limit or a reliable count of user-perceived characters. |
| minlength | non-negative integer | Sets the minimum length of user-entered nonempty text in applicable fields, measured in UTF-16 code units. Add required if an empty value must also be invalid. |
| pattern | JavaScript regular expression source | Adds a whole-value pattern constraint to supported text-like inputs. Modern HTML uses Unicode Sets (v flag) semantics. Do not wrap the pattern in slash delimiters; combine with required to reject empty input. |
| placeholder | short text hint | Shows a temporary hint when a supported form field is empty. It disappears during entry and is not a substitute for a persistent accessible label. |
| readonly | boolean | Prevents user editing of eligible inputs and textareas without disabling their normal submission. It does not apply to every control type, and scripts can still alter the value. |
| required | boolean | Makes supported form controls subject to a nonempty or selected-value constraint. Radio-group and checkbox behavior differs. It does not perform server-side validation. |
| size | positive integer | On applicable text inputs, suggests width in characters; on select, specifies a visible option count. It does not constrain the text length or number of choices. |
| list | datalist ID | Associates a supported input with a datalist of suggestions. It does not restrict the input to the listed values; use select when a closed set is required. |
Return Value
HTMLInputElement
Void form-associated element; no child content. The DOM value and form-submission behavior depend on the input state.
Working Example
Example Snippethtml
<label> Find a book <input type="search" name="q"></label>