Home / Learn HTML / HTML Input Attributes

HTML Input Attributes

Every attribute you can put on a form field, with a live example.

In shortUse placeholder, required, min, max, pattern and autocomplete to build friendly forms.

Definition

Input attributes change how a form control behaves: they give hints (placeholder), rules (required, pattern), limits (min, max), help (autocomplete, list) and state (disabled, readonly, autofocus).

Theory in plain words

Common input attributesrequired: must be filledpattern: format rulemin / max / step: number limitsautocomplete: use saved data
Common input attributes

What it is

Input attributes such as placeholder, required, pattern, min, max, step, autocomplete and list refine how an input behaves.

Why we use it

They add validation, hints and helpers without JavaScript.

How it works

The browser reads each attribute and changes the control: it checks the value, shows hints or offers saved data.

Where it is used

  • Signup forms
  • Checkout forms with autocomplete
  • Number and date limits
valueTry it Yourself
readonlyTry it Yourself
disabledTry it Yourself
sizeTry it Yourself
maxlengthTry it Yourself
min and maxTry it Yourself
multipleTry it Yourself
patternTry it Yourself
placeholderTry it Yourself
requiredTry it Yourself
stepTry it Yourself
autofocusTry it Yourself
autocompleteTry it Yourself
listTry it Yourself
height and width (image button)Try it Yourself
form attributeTry it Yourself
formaction and formmethodTry it Yourself
formnovalidateTry it Yourself
nameTry it Yourself

Only fields with a name are sent.

acceptTry it Yourself
capture (phone camera)Try it Yourself
dirname, inputmode, spellcheckTry it Yourself

Quick quiz

1. Which attribute shows a hint inside a box?

2. Only fields with this are sent

3. readonly means

My notes
Ask a question about this lesson