ā¤ Like
šŸ”– Save
šŸ”— Share
@thedevspaceio
@thedevspaceio

HTML Input Types Cheatsheet

@thedevspaceio

šŸ“ 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

TypeExample
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

TypeExample
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

TypeExample
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

TypeExample
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

TypeExample
button
submit
reset
html
<input type="button" value="Click me" />
<input type="submit" value="Send" />
<input type="reset" value="Clear" />

Hidden input

TypeExample
hidden
html
<input type="hidden" name="userId" value="123" />

Common validation attributes

AttributeExample
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.

@thedevspaceio
www.thedevspace.io