⤠Like
š Save
š Share
@thedevspaceio
HTML Input Types Cheatsheet
š HTML Input Types Cheatsheet
HTML input types control what kind of data users can enter and how browsers render and validate form controls.
ā Text-based inputs ā Number and range inputs ā Date and time inputs ā Choice inputs ā File and color inputs ā Button inputs ā Validation attributes
#html #forms #input #validation #frontend #webdev
Text-based inputs
| Type | Example |
|---|---|
text | |
password | |
email | |
tel | |
url | |
search |
html
<input type="text" name="username" value="Example" />
<input type="password" name="password" value="secret" />
<input type="email" name="email" value="hello@example.com" />
<input type="tel" name="phone" value="+1-555-123-4567" />
<input type="url" name="website" value="https://example.com" />
<input type="search" name="search" value="Search..." />Number and range inputs
| Type | Example |
|---|---|
number | |
range |
html
<input type="number" name="quantity" min="1" max="10" value="5" />
<input type="range" name="volume" min="0" max="100" value="50" />Date and time inputs
| Type | Example |
|---|---|
date | |
datetime-local | |
month | |
week | |
time |
html
<input type="date" name="birthday" value="2024-07-12" />
<input type="datetime-local" name="appointment" value="2024-07-12T10:00" />
<input type="month" name="month" value="2024-07" />
<input type="week" name="week" value="2024-W28" />
<input type="time" name="time" value="10:00" />Choice inputs
| Type | Example |
|---|---|
checkbox | Subscribe |
radio | Free Pro |
color | |
file |
html
<input type="checkbox" name="subscribe" checked />
<input type="radio" name="plan" value="free" checked />
<input type="radio" name="plan" value="pro" />
<input type="color" name="favoriteColor" value="#ff0000" />
<input type="file" name="resume" accept=".pdf" />Button inputs
| Type | Example |
|---|---|
button | |
submit | |
reset |
html
<input type="button" value="Click me" />
<input type="submit" value="Send" />
<input type="reset" value="Clear" />Hidden input
| Type | Example |
|---|---|
hidden |
html
<input type="hidden" name="userId" value="123" />Common validation attributes
| Attribute | Example |
|---|---|
required | |
min / max | |
minlength / maxlength | |
pattern | |
step | |
readonly | |
disabled | |
placeholder |
html
<input type="text" required />
<input type="number" min="0" max="100" value="50" />
<input type="text" minlength="3" maxlength="20" value="abc" />
<input type="text" pattern="[A-Za-z]{3}" title="Three letters" value="abc" />
<input type="number" step="5" value="10" />
<input type="text" value="Read only" readonly />
<input type="text" value="Disabled" disabled />
<input type="text" placeholder="Enter your name" />Full-Stack AI Developer Roadmap
From HTML & CSS to working with AI models, all in one structured roadmap.
www.thedevspace.io