Form-Field Attributes

Autofocus support [<input type="text" autofocus>]

Support for placing the focus on a specific form element. [C5, S4]

Referenced in Tip 6, Jumping to the First Field with Autofocus

Placeholder support [<input type="email" placeholder="me@example.com">]

Support for displaying placeholder text inside of a form field. [C5, F4, S4]

Referenced in Tip 7, Providing Hints with Placeholder Text

Required fields [<input type="email" required>]

Prevent submission of pages unless the fields are filled in. [C23, F16, IE10, O12]

Referenced in Tip 8, Validating User Input without JavaScript

Validation via regex [<input pattern="/^(\s*|\d+)$/">]

Prevents submission of pages unless the field’s content matches the pattern.

Get HTML5 and CSS3, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.