Michael Gearon

HTML form input type’s

Michael Gearon

Last updated on

HTML5 Input Types

In the previous post about Disabling Autocomplete, Autocapitalise  and Autocorrect we looked at how we can improve forms for mobile and desktop use. This post will look at input types, specifically the url, phone and email.

The Syntax for different input types

Very similar to a standard text input you declare the type as “email” or “url” or “phone”:

<input type="phone" value=" " />
<input pattern="[^ @]*@[^ @]*" type="email" value=" " />
<input type="url" value=" " />

On a mobile device the input type phone will show the numbers on the keyboard, the email address input type will show the @ sign and the URL input type will show the forward slash, .co.uk (or .com).


Grab your nearest tablet or smartphone and try it out:

See the Pen NqBYyV by Michael Gearon (@michaelgearon) on CodePen.

The purpose of HTML5 input types

Here are some of the advantages of using the correct input types:

  • Mobile Accessibility – this is very important, if it was the standard text input box then the keyboard won’t recognise that the user has to input a phone number, email or a website URL. By telling the browser this the keyboard can then adapt so if it was a number then the keyboard changes to a number layout, if it is a email then a “@” shows and if it is a URL then “.co.uk” and “.” show.
  • The input type is more semantically correct
  • Easier to style all email input types with [type=email], phone with [type=phone] and url with [type=email]


There is plenty of new stuff in HTML5 to make use of, improving accessibility and making people lives easier whether you are using the website or developing a website. It is also possible to use HTML5’s required attribute alongside the input type to make sure the form is valid, although it is best to use PHP or something else to double check a form, by using HTML5 we can then style it with CSS without the need for Javascript so much.

Further reading

Michael Gearon

Written by

Michael Gearon

Senior Interaction Designer and Co-Author to Tiny CSS Projects