Skip to main content

Input

The label sits inside the field like a placeholder and moves up when the field has focus or a value. It uses peer on the input, placeholder=" " and peer-not-placeholder-shown:, so it needs no JavaScript. The label is a real <label for>, so it still names the field for assistive tech.

Textarea

element="textarea" uses the same technique. The label has a background so the text does not run under it when the field scrolls. Resize is fixed, as on the textarea page.

Up to 500 characters.

Select and date

element="select" takes options and value. A select or a date input always shows something (the chosen option or mm/dd/yyyy), so the label never needs to sit in the middle. Keep it small and on top.

States

A field with a value starts with the label up. Disabled and read-only are set on the input; the label follows.

Validation

Constraint attributes such as required let the browser check the value when the form is sent. error shows a message at once and turns the frame and the label red, for an error the server returns.

Use an address like name@example.com.

This username is already taken.