I saw an HTML5 date input the other day, which had the dropdown arrow on the right, which I’ve grown accustom to clicking to reveal a calendar datepicker in which to choose a date.
Typically, that looks like this:

<input type="date">
I’ve seen variations on this before, like when you use a week input instead of date:

<input type="week">
But I hadn’t seen this before:

Turns out that’s what you get when you apply a <datalist>
to an input of that type! Who knew!
The format is like this:
<input list="days" type="date">
<datalist id="days">
<option label="Chris' Birthday">1980-08-26</option>
<option label="Apollo 11 Moon Landing">1969-07-20</option>
<option label="DDay">1944-06-06</option>
</datalist>
The values for each of the options just need to be valid values for the input, otherwise, they just don’t show up.
Browser Support
As far as I understand it, the spec doesn’t dictate any particular UI requirements for HTML5 input types. If a browser wants to build a datepicker thingy, great, but not doing it doesn’t violate the spec. Thus, this additional UI nicety also isn’t required. I just mention that because lack of “support” here doesn’t indicate a browser is doing a bad job.
These fancy datalist inputs appear to largely be a Blink thing.
A quick check around the latest version of browsers, just testing input type="date"
with a datalist
:
- Chrome 38 = works
- Opera 23 = works
- Safari 8.0 = doesn’t support input type=”date”
- Firefox 32 = doesn’t support input type=”date”
- Internet Explorer 11 = doesn’t support input type=”date”
- iOS 8.1 = date works / datalist doesn’t (see screenshot)
- Android 5 = works (see screenshot)
- Opera Mobile 11.5 = date works / datalist doesn’t
“Support” again meaning “doesn’t do anything special for” – but falls back to a useable text input.


Here’s the rub with features like this. If it’s just a little nicety you can provide, but not crucial, just use it and think of it as progressive enhancement. If it’s totally vital that all users to your site need UI for choosing recommended options and you support browsers that don’t support this, you’ll need either a polyfill or a custom solution.
Other Types
Date doesn’t get to have all the fun! While putting this together, I ran across Eiji Kitamura’s comprehensive test page for all this. It’s not just text
and date
inputs that datalist
can work for, it’s all the variety of date
inputs as well as color
and range
!
type="range"




type="color"



This is cool concept, thanks for sharing.
This has just blown my mind a little! Great find Chris!
The “ tag is such an improvement to the way we input dates, but I don’t think the fallback for unsupported browsers are very nice, with just a normal text input. Firefox should be able to support such a simple thing.. Any suggestions on an alternate date-picker (not jQuery UI)?
KendoUI
Wow, it’s awesome :D
@Thore Cardel
Here is the same datalist page using a polyfill:
http://afarkas.github.io/webshim/demos/demos/webforms/datalist-experiment.html?polyfillall
Latest version of firefox is 33. Just sayin……..
Awesome tip, interested to see how customisable datalist could be. Anyway, in it’s basic form a major win for the end users… especially moble
This is great! Does anyone know how to change the language on the datepicker? I tried declaring but it still shows in English.
Apologies, I dont seem to be able to escape the code: html lang=”fr”
Since the date picker is a browser widget, it probably matches the system language instead of the page language.
From HTML5 Rocks:
Interesting that UI isn’t in the spec at all… That isn’t something I ever really thought about. It makes sense, but it also seems a little dangerous… We already have enough fragmentation to deal with. :P I like your “think of it as a progressive enhancement” view though. Thanks for the roundup!
Glad of being subscribed to your list!
thank you for sharing
//I hope everything gets formatted correctly since the Preview isn’t working… Here we go.
I decided to run some tests in IE.x and my results were mixed:
IE11 and IE10: Partial support, but very faulty. Both browsers behave exactly the same with this type of input. The datalist works when you click on the input field (you can see the dropdown)
but only the labels in the option elements are displayed, not the values. The input controls aren’t displayed either.
Screenshots:
http://imagizer.imageshack.com/img674/9082/LmBZqa.png
http://imagizer.imageshack.com/img674/5867/2RkAsW.png
IE9: No support+. Labels are printed right next to the input field. Option elements are styled (red background) and input field.
Screenshot:
http://imagizer.imageshack.com/img537/8379/RK4dNA.png
IE8: No support at all. Labels are printed right next to the input field and nothing is styled, except the input field.
Screenshot:
http://imagizer.imageshack.com/img661/2075/dIjmAg.png
Here’s the markup I used:
This could really help with conversion, especially on touch devices. I personally don’t think the default fallback of a text-input is that bad really.
It’s a shame that this doesn’t work with “. Be really cool to be able to have control over the numbers that the user can jump between.
Never mind, it seems that it actually does, as long as the datalist only contains integers.
Also, I think your comments section is omitting the
inline
code sometimes…Awesome code, I am using chrome browser, i tried this code for date format..Really working well..Simple and so easy. How to create HTML Table with border attribute?
You could have taken these dates as example. ;-)
Via html5
i don’t know what useful datalist. Thank you for that :)