Skip to content

thewestboy/html-input-types-reference

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

HTML Input Types β€” The Complete Reference

A practical, interactive guide to all 22 HTML5 input types β€” with live previews, copy-ready code, and real-world form patterns.

License: MIT Version GitHub Stars GitHub Forks GitHub Issues Last Commit HTML5 CSS3 JavaScript Vanilla JS Responsive Accessibility GitHub Pages

Report an Issue


πŸš€ Live Demo

https://thewestboy.github.io/html-input-types-reference


πŸ“‘ Table of Contents


✨ Features

  • πŸ“‹ 22 input types, fully documented β€” text, email, password, search, tel, url, number, range, date, time, month, week, datetime-local, checkbox, radio, color, file, submit, reset, button, image, hidden
  • πŸ“ Live previews β€” every card has a working input you can interact with
  • πŸ“‹ One-click copy β€” copy buttons on every code block with visual feedback
  • πŸ§ͺ Real registration form β€” a complete sign-up flow combining multiple input types
  • ⚠️ Common mistakes section β€” side-by-side wrong vs. correct markup with explanations
  • πŸ“Š Cheat sheet table β€” quick-reference table with type, purpose, example, and browser support
  • 🎨 Dark theme design β€” glassmorphism cards, subtle glows, and native dark form controls via color-scheme: dark
  • πŸ“± Fully responsive β€” clean layouts from 320px mobile to large desktop
  • β™Ώ Accessibility-minded β€” semantic HTML, proper labels, focus-visible styles, reduced-motion support
  • ✨ Interactive polish β€” scroll progress bar, section highlighting, reveal-on-scroll animations, hero parallax tilt, back-to-top button

πŸ›  Tech Stack

Layer Technology
Markup HTML5 (semantic elements, ARIA roles, SVG icon sprite)
Styling CSS3 (custom properties, Grid, Flexbox, clamp(), backdrop-filter, CSS masking)
Scripting Vanilla JavaScript (ES6+, no dependencies)
Fonts Inter (UI) + JetBrains Mono (code) via Google Fonts
Build Tooling None β€” zero-config static site
Package Manager None β€” no package.json or external packages

ℹ️ This project intentionally ships with no framework, bundler, or dependency β€” it's pure HTML/CSS/JS, runnable by simply opening index.html or serving the folder statically.


πŸ“ Project Structure

html-input-types-reference/
β”œβ”€β”€ index.html          # Single-page document (all sections, modals, form)
β”œβ”€β”€ style.css           # Complete stylesheet β€” design tokens, layout, responsive rules
β”œβ”€β”€ script.js           # All client-side behavior β€” player, modals, form, interactions
β”œβ”€β”€ images/
β”‚   └── cover.png       # Repository cover image
β”œβ”€β”€ README.md           # This file
└── LICENSE.md          # MIT License

The entire site is contained in three files. No node_modules, no build output, no external assets beyond the two Google Fonts requests.


βš™οΈ Installation

No build step, no dependencies, no package manager required.

# Clone the repository
git clone https://github.com/thewestboy/html-input-types-reference.git

# Move into the project directory
cd html-input-types-reference

That's it β€” there is nothing to npm install.


πŸš€ Getting Started

You can run this project in two ways:

Option 1 β€” Open directly

Simply open index.html in your browser.

Option 2 β€” Serve locally (recommended)

# Using Python
python3 -m http.server 8000

# Or using Node's http-server (if installed globally)
npx http-server .

Then open http://localhost:8000 in your browser.


πŸ”§ Configuration

There are no environment variables or .env files β€” all configuration lives directly in the source files:

What Where
Site metadata (title, description, OG tags) index.html <head>
Design tokens (colors, spacing, fonts, radii) :root CSS custom properties in style.css
Section content and markup index.html body
Interactive behavior script.js

πŸ“ Before deploying: Update the <meta> tags in index.html with your own site description and Open Graph data if you fork this project.


πŸ’‘ Usage

This project is a reference, not a library. Use it to:

  1. Look up an input type β€” jump to the relevant section via the nav or in-page links
  2. Copy code β€” click the copy button on any code block to grab the markup
  3. Test on mobile β€” open the page on a phone to see how each input type triggers the correct virtual keyboard
  4. Check the cheat sheet β€” bookmark the table section for a quick lookup of all 22 types
  5. Review the mistakes section β€” avoid common pitfalls like using type="number" for phone numbers

πŸ“± Responsive Design

The layout adapts across five breakpoints:

Range Layout
320–480px Single column, stacked hero CTAs, full-width cards, 16px input font (prevents iOS zoom)
481–640px Two-column float chips, maintained card spacing
641–860px Two-column grids for cards, side-by-side form rows
861–1024px Three-column float chips, two-column card grids
1025–1280px Four-column float chips, full desktop layout
1281px+ Original desktop design

Touch devices get enhanced tap targets (44px minimum) via the pointer: coarse media query.


⚑ Performance

Metric Value
Total page weight ~116 KB (HTML + CSS + JS)
External requests 2 (Google Fonts)
JavaScript size 6.2 KB (unminified)
CSS size 46.9 KB (unminified)
No render-blocking JS All scripts are deferred via async IIFE
Passive scroll listeners { passive: true } on scroll events
will-change hints Applied to animated elements for GPU compositing

The page scores well on Core Web Vitals because there is no JavaScript framework to hydrate, no large CSS framework to parse, and no external images to fetch.


β™Ώ Accessibility

  • Semantic HTML β€” <main>, <nav>, <section>, <article>, <form>, and proper heading hierarchy
  • Labels β€” Every interactive input has an associated <label> (not just placeholder text)
  • Focus management β€” Visible focus rings, logical tab order, and keyboard-navigable mobile menu
  • Screen readers β€” aria-label, aria-hidden, and sr-only text where visual labels aren't sufficient
  • Motion β€” prefers-reduced-motion respects user settings and disables animations
  • Color contrast β€” Text colors meet WCAG AA standards against the dark background
  • Tables β€” Sticky headers and horizontal scroll with touch momentum on narrow screens

🌐 Browser Support

Browser Supported
Chrome (latest) βœ…
Firefox (latest) βœ…
Safari (latest) βœ…
Edge (latest) βœ…
iOS Safari βœ…
Android Chrome βœ…
IE11 ❌

Relies on modern CSS (Grid, custom properties) and ES6+ JavaScript β€” no transpilation or polyfills are included.


🚒 Deployment

This is a static site, so it can be deployed to any static host with zero build configuration.

Deploy to Netlify
  1. Push this repository to GitHub.
  2. In Netlify, click Add new site β†’ Import an existing project.
  3. Select the repository β€” leave the build command empty and set the publish directory to /.
  4. Deploy.
Deploy to Vercel
  1. Push this repository to GitHub.
  2. In Vercel, click Add New β†’ Project and import the repo.
  3. Framework preset: Other. No build command required.
  4. Deploy.
Deploy to GitHub Pages
  1. Push this repository to GitHub.
  2. Go to Settings β†’ Pages.
  3. Set the source branch to main and the folder to / (root).
  4. Save β€” your site will be live at https://thewestboy.github.io/html-input-types-reference/.

🎯 Learning Goals

If you're studying this codebase, here are the specific techniques worth noting:

CSS

  • Custom properties (variables) for a maintainable design system
  • clamp() for fluid typography that scales smoothly between breakpoints
  • backdrop-filter for glassmorphism card effects
  • CSS Grid with minmax(0, 1fr) to prevent overflow in dense layouts
  • color-scheme: dark to theme native form controls (calendars, checkboxes, file inputs)
  • CSS masking for the subtle grid background fade
  • Keyframe animations with custom easing curves

JavaScript

  • Intersection Observer API for scroll-triggered reveals and nav section highlighting
  • Clipboard API with graceful fallback to document.execCommand
  • requestAnimationFrame for smooth parallax tilt without jank
  • Passive event listeners for scroll performance
  • Touch-friendly event handling for mobile menu dismissal

HTML

  • SVG sprite sheets β€” all 33 icons are defined once and referenced via <use>
  • Semantic sectioning β€” proper use of <section>, <article>, and <form>
  • Native input behavior β€” leveraging browser validation, keyboards, and pickers instead of custom widgets

πŸ—Ί Roadmap

  • Add inputmode attribute examples alongside each type
  • Include autocomplete attribute recommendations
  • Add a "copy all" button for the full registration form markup
  • Include pattern regex examples for tel and custom validations
  • Add a contrast checker tool for the color input demo
  • Dark/light theme toggle (currently dark-only)
  • Search/filter the cheat sheet table
  • Print-friendly stylesheet for the cheat sheet

🀝 Contributing

This is a personal reference project, but suggestions and corrections are welcome. If you spot an error in the documentation or a browser support note that needs updating, feel free to open an issue.

  1. Fork the repository
  2. Create a feature branch (git checkout -b fix/typo-or-improvement)
  3. Commit your changes
  4. Open a pull request

Please keep the scope focused β€” this is a reference page, not a component library.


❓ FAQ

Do I need Node.js or npm to run this?

No. This is a pure static site β€” just open index.html or serve the folder with any static file server.

Why does the page look dark?

The design is intentionally dark-themed. There is no light mode toggle yet β€” it's on the roadmap.

Can I use this as a template for my own reference site?

Yes β€” it is MIT licensed. Swap out the content, branding, colors, and it is ready to go.


πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.


πŸ‘€ Author

TheAria Azimi


⭐ If you find this project useful, consider giving it a star!

It helps others discover the project and motivates continued development.

Star on GitHub

Releases

Packages

Contributors

Languages