Skip to main content
Beta: Front-End Checklist is currently in beta. Some issues are still being fixed. Thanks for your patience.
HTMLHigh

Use semantic input type attributes

Set the correct type attribute on input elements to trigger the right mobile keyboard, enable browser validation, and improve autofill accuracy.

Utilities
Quick take
Typical fix time 10 min
  • type=email shows the @ keyboard on mobile and enables email format validation
  • type=tel shows the numeric phone keypad on mobile
  • type=number shows a numeric keypad; use inputmode=numeric for fields that look like numbers but aren't
  • type=date/time renders native pickers and returns standardized values
Why it matters: Using type=text for every input forces mobile users to switch keyboards manually for email, phone, and number entry. The correct type also enables browser autofill to correctly identify fields for name, address, and payment data. Combined with autocomplete attributes, semantic types can make form completion 40% faster for returning users.

Rule Details

The type attribute is one of the most impactful and underused HTML attributes — it directly affects mobile keyboard display, browser validation, and autofill.

Code Example

<!-- Text inputs -->
<input type="text">      <!-- Default. General text. QWERTY keyboard on mobile -->
<input type="email">     <!-- Email address. Adds @ and .com key on mobile -->
<input type="tel">       <!-- Phone number. Shows numeric dialpad on mobile -->
<input type="url">       <!-- URL. Shows / : . and .com keys on mobile -->
<input type="search">    <!-- Search. Shows search/return key on mobile -->
<input type="password">  <!-- Masked input for passwords -->
 
<!-- Number inputs -->
<input type="number">    <!-- Numeric keypad. Use for quantities you can increment -->
<input type="range">     <!-- Slider for a range of values -->
 
<!-- Date and time inputs -->
<input type="date">      <!-- Date picker. Returns YYYY-MM-DD -->
<input type="time">      <!-- Time picker. Returns HH:MM -->
<input type="datetime-local">  <!-- Combined date and time -->
<input type="month">     <!-- Month and year picker -->
<input type="week">      <!-- Week picker -->
 
<!-- Other inputs -->
<input type="color">     <!-- Color picker -->
<input type="file">      <!-- File upload -->
<input type="checkbox">  <!-- Boolean checkbox -->
<input type="radio">     <!-- Radio button group -->
<input type="hidden">    <!-- Hidden value in form submissions -->

Why It Matters

Using type=text for every input forces mobile users to switch keyboards manually for email, phone, and number entry. The correct type also enables browser autofill to correctly identify fields for name, address, and payment data. Combined with autocomplete attributes, semantic types can make form completion 40% faster for returning users.

inputmode for Mobile Keyboards

inputmode controls the keyboard without affecting validation:

<!-- Numeric input that looks like text (e.g., credit card) -->
<input type="text" inputmode="numeric" pattern="[0-9]*">
 
<!-- ZIP code: numbers but shouldn't spin/validate as number -->
<input type="text" inputmode="numeric" autocomplete="postal-code">
 
<!-- Decimal values (shows decimal key on mobile) -->
<input type="text" inputmode="decimal">
inputmodeMobile Keyboard
textDefault QWERTY
numericNumber pad (0-9)
decimalNumber pad with decimal
telPhone dial pad
emailEmail keyboard
urlURL keyboard
searchSearch keyboard

autocomplete for Autofill

<form>
  <!-- Name -->
  <input type="text" autocomplete="name" placeholder="Full name">
  <input type="text" autocomplete="given-name" placeholder="First name">
  <input type="text" autocomplete="family-name" placeholder="Last name">
 
  <!-- Contact -->
  <input type="email" autocomplete="email">
  <input type="tel" autocomplete="tel">
 
  <!-- Address -->
  <input type="text" autocomplete="street-address">
  <input type="text" autocomplete="address-level2"> <!-- City -->
  <input type="text" autocomplete="postal-code">
  <input type="text" autocomplete="country-name">
 
  <!-- Payment -->
  <input type="text" autocomplete="cc-name" inputmode="text">
  <input type="text" autocomplete="cc-number" inputmode="numeric">
  <input type="text" autocomplete="cc-exp" placeholder="MM/YY">
  <input type="text" autocomplete="cc-csc" inputmode="numeric">
 
  <!-- Authentication -->
  <input type="email" autocomplete="username">
  <input type="password" autocomplete="current-password">
  <input type="password" autocomplete="new-password"> <!-- For registration -->
</form>

Standards

  • Use MDN: HTML as the standard for the final rendered HTML and browser-facing behavior.
  • Use WHATWG HTML Living Standard as the standard for the final rendered HTML and browser-facing behavior.

Verification

Automated Checks

  • Inspect the final rendered HTML in the browser or page source to confirm the rule is satisfied.
  • Validate the affected markup with browser tooling or an HTML validator where appropriate.
  • Test one representative route or template that uses the pattern.
  • Re-check shared components that emit the same markup so the fix is consistent.

Manual Checks

  • Verify the rendered browser behavior manually on representative routes and supported browsers so the user-facing outcome matches the rule.

Use with AI

Copy these prompts to use with your AI assistant, or install the MCP server to use directly from Claude, Cursor, or Windsurf.

Check

Verify implementation

Audit all input elements in this HTML file. Check whether each uses the most appropriate type attribute and autocomplete value.

Fix

Auto-fix issues

Update input type attributes to semantic values and add appropriate autocomplete attributes for autofill support.

Explain

Learn more

Explain the different HTML input types, what each one does on mobile keyboards, and how to combine them with autocomplete attributes.

Review

Code review

Review templates, server-rendered HTML, and shared components that output markup related to Use semantic input type attributes. Flag exact elements, attributes, and routes where the rendered HTML violates the rule.

Sources

References used to support the guidance in this rule.

Further Reading

Tools and supplementary material for exploring the topic in more depth.

MDN input type referencedeveloper.mozilla.orgTool
inputmode referencedeveloper.mozilla.orgTool

Rules that often go hand-in-hand with this one.

Validate forms accessibly

Forms provide clear validation feedback with accessible error messages and proper ARIA attributes.

HTML
Use semantic HTML elements

HTML5 Semantic Elements are used appropriately (header, section, footer, main, article, aside...).

HTML
Make search inputs accessible

Search functionality is accessible with proper input type, label, role, and autocomplete suggestions.

HTML
Make file uploads accessible

File upload components are accessible with proper labels, file type restrictions, and progress feedback.

HTML

Was this rule helpful?

Your feedback helps improve rule quality. This stays internal for now.

Loading feedback...
0 / 385