Skip to main content
← πŸ“„ HTML & the platformΒ·Module A3 Β· Lesson 2
TaskBuild a contact form with three inputs: email (name='email'), website url (name='website'), phone (name='phone' type='tel'). Plus a submit button.

<input type=email|url|tel>: browser validation, free

75 XP6 min
Theory

Choose the right type, get validation for free

<input type="email" />   <!-- requires @ and a domain -->
<input type="url" />     <!-- requires scheme + host -->
<input type="tel" />     <!-- mobile keyboard switches to number pad; NO format validation -->
<input type="search" />  <!-- styles with a clear "x" button + ESC clears -->
<input type="password" />

Browser validates on submit. If the user types "anna" into type="email", the browser shows a native tooltip "Please include an @" and blocks the submit. No JS needed.

type=tel is special

It changes the on-screen keyboard on mobile (numbers + symbols) but does NOT validate format. Phone formats vary too much (US: 555-1234, UK: 020 7946 0958, etc.). Pair with pattern or backend validation.

type=email accepts ONE address by default

For multiple recipients: <input type="email" multiple />. The browser then validates a comma-separated list.

Mobile keyboard switching

Beyond keyboard for tel, also:

  • type="number" β€” number pad
  • type="email" β€” keyboard with @ and . prominent
  • type="url" β€” keyboard with / and .com prominent
  • type="search" β€” keyboard with a "Search" button instead of "Return"

Pick the right type. Mobile users notice.

πŸ”’

Sign up to start coding

Theory is open to everyone. The interactive editor, live preview, and check are unlocked with a 7-day free trial β€” card required, cancel anytime.

Sign up β€” free trial β†’

First 10 lessons in each track are free. No card needed for those.

← PreviousNext lesson β†’

Get one Python or web tip a day β€” by email

Short, hand-written, no spam. Unsubscribe in one click.