Using HTML5 Input Types to Enhance The Mobile Browsing Experience
Browsing the web on mobile devices has become incredbily popular over the past few years. However the browsing experience on these devices can sometimes leave a lot to be desired. This is especially true when it comes to filling in forms. Luckily the HTML5 specification introduces a number of new input types that make it easier for users to fill in your web forms on mobile devices.
In a rather awesome move, mobile browser vendors picked up on the new HTML5 input types and are using them to display customized keyboard layouts that make it easier for users to enter data.
In this blog post you are going to learn about eight new input types that have been introduced in HTML5.
Note: The iOS screenshots in this post were taken using an iPhone 5 and Safari. The Android screenshots were taken using a virtual device running Android 4.1 and the stock web browser.
@ and period (
.) keys in the bottom row of the iOS keyboard. On Android, the standard comma key that would appear to the left of the space bar has been replaced with an
<input type="email" name="email">
url input type can be used to help users input web addresses. On iOS the whole space bar has been replaced with period (
.) and forward-slash (
/) keys as well as a special
My testing showed no changes to the Android keyboard.
<input type="url" name="url">
Telephone Number Inputs
tel input type prompts both iOS and Android to display a dialer keypad instead of the standard keyboard.
<input type="tel" name="tel">
number input type causes iOS to present a keyboard with numbers and punctuation. The Android browser will launch a keypad similar to the one displayed for telephone inputs.
<input type="number" name="number">
There are also a number of input types available for dates and times. These can be really useful as they ensure that your data is provided in a standardized format.
On iOS the
date input type will prompt a date picker to be displayed. Unfortunately the Android browser does not yet have support for any datetime input types.
<input type="date" name="date">
time type will prompt iOS to display a simple picker for selecting hours and minutes.
<input type="time" name="time">
Date and Time Inputs
datetime type will display a picker for selecting both a date and time.
Although there is no option for explicitly selecting a year, the picker will automatically add a year to your input based on the date and month that you select.
<input type="datetime" name="datetime">
month type will display a simplified version of the date picker.
The HTML specification also defines a
week input type, however this does not seem to have been implemented in either of the browsers I tested.
<input type="month" name="month">
Browser Compatibility For HTML5 Input Types
Browsers that do not support these new input types will just display a simple text input to users. This means that you can go ahead and start using these new input types today!
Support for the date/time input types amongst desktop browsers is still very limited. Opera currently has the best implementation, supporting all of the types mentioned in this post. Google Chrome has support for the
date type but nothing else at the moment. Safari has date-formatted text fields but does not support the calender widget that is displayed in Opera and Chrome.
Fortunately the days of having to endure a poor browsing experience on mobile are swiftly on the way out. By taking advantage of the new mobile-friendly features introduced in HTML5 we can confidently deliver an enjoyable experience to all of our users, regardless of the device they are using.
Comments are closed.
Front End Web Design
User Experience (UX) Design
iOS Development with Swift
Python Web Development
Each is designed by our faculty of tech professionals to guide even a coding beginner to becoming a job-ready software developer armed with a professional portfolio of real-world projects. Try one out today with our free seven-day trial, and see if software development is for you.