HTML 5 brings new input types to supplement the standard text input. Notably:
- url
- number
- range
- date
- search
- color
If you've dabbled with these input types, you may initially see no value in them. But, here are a few reasons to get comfortable with them and start using them consistently in your web development:
- Why not! The don't cause any compatibility issues. If an older browser doesn't recognize the input type, it will default to text.
- Validation. Some browsers will force validation on certain input types, such as email.
- Mobile Support. Mobile phones such as the iPhone offer alternative keyboards or widgets depending on the input type. For instance, if iPhone recognizes a number input, it will switch to the numeric keyboard.
There are many resources out there that explain these new HTML 5 input types in depth.
Code Example:
<input type="email" name="contact_email" id="contact_email" />