HTML5 Input Types

HTML5 New Input Types

HTML5 has several new input types for forms. These new features allow better input control and validation.
This chapter covers the new input types:
  • color
  • date
  • datetime
  • datetime-local
  • email
  • month
  • number
  • range
  • search
  • tel
  • time
  • url
  • week
Note: Not all major browsers support all the new input types. However, you can already start using them; If they are not supported, they will behave as regular text fields.

Input Type: color

The color type is used for input fields that should contain a color.
Opera Safari Chrome Firefox Internet Explorer

Example

Select a color from a color picker:
Select your favorite color: <input type="color" name="favcolor" />

Input Type: date

The date type allows the user to select a date.
Opera Safari Chrome Firefox Internet Explorer

Example

Define a date control:
Birthday: <input type="date" name="bday" />
 

Input Type: datetime

The datetime type allows the user to select a date and time (with time zone).
Opera Safari Chrome Firefox Internet Explorer

Example

Define a date and time control (with time zone):
Birthday (date and time): <input type="datetime" name="bdaytime" />

Input Type: datetime-local

The datetime-local type allows the user to select a date and time (no time zone).
Opera Safari Chrome Firefox Internet Explorer

Example

Define a date and time control (no time zone):
Birthday (date and time): <input type="datetime-local" name="bdaytime" />
 

Input Type: email

The email type is used for input fields that should contain an e-mail address.
Opera Safari Chrome Firefox Internet Explorer

Example

Define a field for an e-mail address (will be automatically validated when submitted):
E-mail: <input type="email" name="usremail" />
Tip: Safari on iPhone recognizes the email type, and changes the on-screen keyboard to match it (adds @ and .com options).

Input Type: month

The month type allows the user to select a month and year.
Opera Safari Chrome Firefox Internet Explorer

Example

Define a month and year control (no time zone):
Birthday (month and year): <input type="month" name="bdaymonth" />

Input Type: number

The number type is used for input fields that should contain a numeric value.
You can also set restrictions on what numbers are accepted:
Opera Safari Chrome Firefox Internet Explorer

Example

Define a numeric field (with restrictions):
Quantity (between 1 and 5): <input type="number" name="quantity" min="1" max="5" />
Use the following attributes to specify restrictions:
  • max - specifies the maximum value allowed
  • min - specifies the minimum value allowed
  • step - specifies the legal number intervals
  • value - Specifies the default value
Try an example with all the restriction attributes: Try it yourself

Input Type: range

The range type is used for input fields that should contain a value from a range of numbers.
You can also set restrictions on what numbers are accepted.
Opera Safari Chrome Firefox Internet Explorer

Example

Define a control for entering a number whose exact value is not important (like a slider control):
<input type="range" name="points" min="1" max="10" />
Use the following attributes to specify restrictions:
  • max - specifies the maximum value allowed
  • min - specifies the minimum value allowed
  • step - specifies the legal number intervals
  • value - Specifies the default value

Input Type: search

The search type is used for search fields (a search field behaves like a regular text field).
Opera Safari Chrome Firefox Internet Explorer

Example

Define a search field (like a site search, or Google search):
Search Google: <input type="search" name="googlesearch" />

Input Type: tel

Opera Safari Chrome Firefox Internet Explorer

Example

Define a field for entering a telephone number:
Telephone: <input type="tel" name="usrtel" />
 

Input Type: time

The time type allows the user to select a time.
Opera Safari Chrome Firefox Internet Explorer

Example

Define a control for entering a time (no time zone):
Select a time: <input type="time" name="usr_time" />

Input Type: url

The url type is used for input fields that should contain a URL address.
The value of the url field is automatically validated when the form is submitted.
Opera Safari Chrome Firefox Internet Explorer

Example

Define a field for entering a URL:
Add your homepage: <input type="url" name="homepage" />
 Tip: Safari on iPhone recognizes the url input type, and changes the on-screen keyboard to match it (adds .com option).

Input Type: week

The week type allows the user to select a week and year.
Opera Safari Chrome Firefox Internet Explorer

Example

Define a week and year control (no time zone):
Select a week: <input type="week" name="week_year" />

HTML5 <input> Tag

Tag Description
<input> Defines an input field

Partner site : online news
 

What Could Top Rankings Mean For Yours?

The success of Enviro Friendly has been built on the foundation of a website that enjoys high search engine rankings for all our important keywords. We were already a successful business long before we moved from my third bedroom to retail premises (pictured above) in April 2006. Over the last year, we have been enjoying over 1600 unique visitors per day, and over 1.25 million pageviews a year. How do we manage that?
In 2000, I launched a website and ezine called Web School to provide a 'bridge' between businesspeople who knew business, but nothing about Internet, email and electronic Marketing, and knowledgeable computer people who knew nothing about business. At it's height, I had over 5000 subscribers world-wide.
Within a couple of years of founding WebMarketing Ezine, we'd formed Enviro Friendly. With time at a premium, I chose to apply what I knew about Web Marketing to our own business, and let the WME site languish. It was obviously the right decision, as Enviro Friendly is now a multi-million dollar business growing at close to 100% a year.
You're almost certainly reading this because you found our site through it having a high-ranked search engine listing for the search term you were using. That's the way over 80% of our 1600 visitors a day find us. High search engine rankings in Google, Yahoo! etc., bring us around $ 2,000,000 in sales a year, so they really pay off.
In the WebMarketingEzine days, my son (and partner) David and I produced websites for clients, some as far away as Miami. Our knowledge of website design and search engine optimisation enabled us to achieve excellent results for our clients. These days, we're often asked by business associates if we can create a website for them. Unfortunately, we don't have the time to do that ourselves. But there is a way we can help...
Most web designers tend to be good at graphics, and/or database-driven systems.
Sadly, most web designers know next-to-nothing about creating a website that will produce a lot of free, targeted traffic from search engines!
There are over 100,000,000 websites. Enviro Friendly gets more traffic than 99.5%!
To us, a website is a means of attracting large numbers of free, targeted customers, and offering to help them with their needs. Could that be valuable for your business?
If you can recognise the immense value that a high-ranking website could have for your business, but don't know how to 'get there', I have three suggestions...
  • find a web designer who really knows search engines, and pay them lots of money, or
  • spend a lot of time and money learning search engine optimisation yourself, or
  • invest in a package that will lead you step-by-step to a highly successful website using the same principles we use on our Enviro Friendly website.
Partner site : online news

Website Development Tips

You can get high rankings and increase web traffic to your site by doing the following steps.  Not following our advice on any tip will result in lower rankings on some search engines.  Please contact us if you need to know "the why" to the below statements:
  • research what keywords people useHome cooking webpage tips most often on search engines that pertain to your products or services;  use these keywords as text in the design to increase website traffic.
  • "Keep It Simple" - 99% of all web designers use too many graphical images and programs like Java, Flash, etc. which results in lower rankings and less traffic..
  • Web pages, like a spread sheet, are made using cells and tables.  Use as few cells and tables in your web design as possible.
  • Create good Meta Tags.  Each page should have different keywords in the Title and the Description Meta Tag.
  • Limit the number of times that you repeat words in your Keyword Meta Tag.
  • Place your important keywords at the top of the page as text headers.
  • Your most important page and keywords should be on the first page of a website.
  • Frames based websites should only be used for Intranet (a site only for company employees) and not for Internet.
  • Do NOT include pages that re-direct (a page that automatically sends you to another page) people to other pages.
  • Run an analysis program to count the number of times keywords are used in the first 7500 characters of computer code.
  • Limit your use of services that automatically submits your URL to the top 10 search engines.
  • When finished with a page, run a spell checking program and then compress the html code.
  • Keep track of your search engine rankings and website traffic.
  • Once a website is indexed, a good web designer should go back and improve pages that didn't get high rankings on key words.
  • Every 3 months you should make a small change on each web page.  Search engines like to see that changes are being made to a site and that it just isn't sitting there for years with no upgrades.



Why Web Designers Don't Follow The Above Tips
  • Time is money.  Most web designers bid on projects and know it takes at least 30% more time to create a site that gets high rankings.  Since most companies / people don't know what should be done to get an increase in website traffic, web designers cut corners and only design a website that the customer sees is appealing.
  • Most web designers haven't taken the time to learn how to get high rankings on multiple search engines.
  • Many web designers don't care about getting high rankings, as it's not fun and creative work.
Partner site : online news