HTML5 Form Attributes

30 HTML Form Attributes

A complete example of HTML forms attributes that shows how they work with validation, work well on mobile, and give users a better experience.

30
Native Attributes
100%
Browser Support
0 KB
JavaScript Required

Form Validation

Built-in input validation and constraints

required pattern minlength maxlength
3-20 characters, alphanumeric only

Smart Autofill

Browser-powered autocomplete

autocomplete autofocus
The first input receives automatic focus on page load. Browser suggests previously saved information.

Mobile Optimization

Context-aware keyboards

inputmode enterkeyhint autocapitalize
Different keyboard layouts appear automatically on mobile devices based on input type.
Decimal keyboard on mobile devices
Numeric keyboard on mobile devices
URL keyboard with domain shortcuts
Enter key displays "Search"

Number & Date Controls

Value constraints and ranges

min max step
Value must be between 18 and 100
Increments of 0.01 for currency
Date range limited to 2025
Business hours: 9 AM - 5 PM, 15-minute intervals
50

File Upload Controls

File type restrictions and multiple selection

accept multiple capture
Accepts multiple image files
PDF, DOC, or DOCX files only
Opens camera on mobile devices

Button Overrides

Different actions per button

formaction formmethod formtarget formnovalidate
Each button can submit to different endpoints with different methods and targets without JavaScript.

Smart Suggestions

Datalist autocomplete options

list datalist
Start typing to see suggestions. Users can select from the list or enter custom values.

Textarea Controls

Text area configuration options

rows cols wrap spellcheck
Spellcheck enabled for natural language content
Spellcheck disabled for code input

Special Attributes

Additional form features

readonly disabled dirname size
Read-only field, value is submitted
Disabled field, value is not submitted
Submits both value and text direction (ltr/rtl)
Size attribute controls visible width

External Form Elements

Form association and validation control

form novalidate
Form validation is disabled. The email input below is outside the form element but linked via form attribute.
This input is outside the form but linked to it

Multiple Values

Multiple email addresses

multiple
Enter multiple email addresses separated by commas. Each email is validated individually.

Complete Registration Form

All attributes combined in a comprehensive example

All 30 Attributes