Text Input

A text input is a basic form control that allows users to enter freeform text. It is the most commonly used input field.

Accessibility Features

Feature types: Required Recommended
  • An input field must have its own visible <label>, associated via matching for and id attributes or nesting. Multiple interactive controls must not be nested inside a single <label>.
  • aria-describedby associates help texts, error messages and prefixes/suffixes with the input field.
  • Placeholder text must not be used as a substitute for a label as it is not permanent and disappears on input.

Single-line Text

The native <input> element should always be used for single-line text, as it provides built-in keyboard support, screen reader announcements and mobile keyboard optimization.

type="text" provides a field for general text. A field that expects a specific kind of value, such as an email address, telephone number or URL, should use the matching type (email, tel or url). The browser can then validate the format on submit and trigger an optimized keyboard on mobile devices.

Example

Code Snippet

Textarea

A <textarea> allows users to enter multiline text. The maxlength attribute limits the number of characters and a visible counter keeps users informed of the remaining characters.

Example

Code Snippet