WEBVTT

0
00:00.490 --> 00:05.800
I know I've spoken about this before, but why would one choose datalist versus select?

1
00:05.920 --> 00:07.060
Or vice versa?

2
00:07.060 --> 00:09.490
When would you want to use one over the other?

3
00:09.490 --> 00:14.170
And this is a great question because they are so similar, but at the same time they're different.

4
00:14.170 --> 00:20.170
And you need to understand when one is more appropriate than the other, which is why I'm just emphasizing

5
00:20.170 --> 00:20.350
this

6
00:20.350 --> 00:22.540
again. It's going to be a very quick lecture, I promise.

7
00:22.570 --> 00:25.360
The main difference boils down to what?

8
00:25.540 --> 00:26.110
That's right.

9
00:26.110 --> 00:31.930
The user's ability to enter their own value. If you will recall, and I'm sure you do, the datalist

10
00:31.930 --> 00:34.740
element allows the user to enter any value.

11
00:34.750 --> 00:41.320
They don't have to select one of our pre-selections, whereas the select element gives the user a predefined

12
00:41.320 --> 00:43.690
set rigid list.

13
00:43.690 --> 00:48.760
And if you think about a typical autocomplete scenario, the suggestions are either going to be based

14
00:48.760 --> 00:52.720
on the user's history or a list of values based on some algorithm.

15
00:52.720 --> 00:58.150
And this basically just means the choices may not be what the user wants to enter.

16
00:58.150 --> 01:00.110
Think about a search engine, for example.

17
01:00.110 --> 01:06.650
Each one has a search suggestion list as you type based on related searches others have previously entered.

18
01:06.680 --> 01:12.740
This may not be the search phrase you need, so that's why browsers allow you to submit anything you

19
01:12.740 --> 01:13.160
want.

20
01:13.190 --> 01:19.520
If, on the other hand, search engines used the select element, then the range of search phrases would

21
01:19.520 --> 01:25.490
be extremely limited and you would pull your hair out and you would not find that acceptable.

22
01:25.490 --> 01:32.150
For the record, 20% of daily queries submitted to search engines are unique and have never been submitted

23
01:32.150 --> 01:32.900
before.

24
01:33.200 --> 01:34.730
I thought that was quite interesting.

25
01:34.730 --> 01:39.770
So anyway, the point I'm trying to make is my preference is always to use datalist where you can because

26
01:39.770 --> 01:43.460
users love choice and they love to be unique.

27
01:43.460 --> 01:45.650
So give them the freedom to do so.

28
01:45.650 --> 01:48.560
Try not to restrict your users where possible.

29
01:48.560 --> 01:49.070
There we go.

30
01:49.070 --> 01:50.570
I told you it was going to be a quick lecture.

31
01:50.570 --> 01:53.660
I just wanted to drive this point home one more time.