Advanced Input Types & Custom Controls
Lesson 19 โข Advanced Track
What You'll Learn
๐ก Think of It Like This
HTML5 input types are like specialised tools. A text input is a Swiss Army knife โ works for everything but nothing perfectly. A type="date" input is a calendar. A type="color" is a paint palette. Using the right input type gives users the best native controls for each data type.
| Input Type | What It Shows | Mobile Keyboard |
|---|---|---|
range | Slider control | N/A |
color | Color picker popup | N/A |
date | Calendar date picker | Date wheel |
time | Time selector | Time wheel |
datetime-local | Date + time combined | Date + time |
search | Searchable text with clear button | Search keyboard |
tel | Phone number input | Numeric pad |
url | URL input with validation | .com keyboard |
HTML5 Input Types Gallery
Try every HTML5 input type in one interactive demo.
All HTML5 Input Types
Interactive gallery of every modern input type
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML5 Input Types</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: #0f172a; font-family: system-ui, sans-serif; color: #e5e7eb; padding: 30px; }
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 15px;
}
.input-card {
background: #1e293b;
padding: 15px;
border-radius: 8px;
}
lab
...Custom Toggle Switch & Styled Checkbox
Build beautiful custom controls using only CSS โ no JavaScript needed.
Custom CSS Controls
Toggle switches and styled checkboxes with pure CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Custom Controls</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: #0f172a; font-family: system-ui, sans-serif; color: #e5e7eb; padding: 30px; }
h2 { color: #3b82f6; margin: 25px 0 15px; }
/* === TOGGLE SWITCH === */
.toggle-label {
display: flex;
align-items: center;
gap: 12px;
cursor: pointer;
margin: 10px 0;
font-size: 15px;
...โ ๏ธ Common Mistakes
- Using type="text" for everything โ Use the right input type (email, tel, url, number) so mobile users get the right keyboard and browsers validate automatically.
- Hiding native inputs without preserving accessibility โ Use
display: noneon the input but keep it inside a<label>so clicking the custom control still toggles the real input. - Forgetting :focus-visible on custom controls โ Keyboard users need visible focus indicators on custom checkboxes and toggles.
- Not providing a datalist fallback โ The datalist element degrades gracefully to a normal text input in unsupported browsers.
๐ Lesson Complete
You can now use and style every HTML5 input type:
- โ Use specialised input types (range, color, date, search) for better UX
- โ Build custom toggle switches, checkboxes, and radios with pure CSS
- โ
Use
<datalist>for autocomplete suggestions - โ Always keep custom controls accessible with labels and focus indicators
Sign up for free to track which lessons you've completed and get learning reminders.