This was a fun little read. Just through testing the examples, I also learned datalist does not seem to work well on mobile safari (which is a large enough market I might even say there’s essentially no scenario in which it’s worth using if there’s a compatibility issue).
The datalist examples definitely work on my iPhone. They integrate into the autocomplete suggestions above the native iOS keyboard. There’s no way to browse all the suggestions, but I suppose that’s not an intended use case for datalist.
However, the disabled attr on group definitely does not work!
It seems the autofill bar only populates with the first three items in the datalist and also does not clear when navigating to a regular text field like this one. Kind of an interesting way to have screwed it up.
Ugh this is the dose of cold water from reality that I didn't want but definitely needed.
More than a decade ago I had a project that used a pretty aggressive input-suggestion widget on the UI. We used a jQuery plugin for it and it was by far the most complicated part of the frontend. In fact, it was the main use-case for jQuery in that project.
Reading the article, I thought it would be pretty much a breeze re-implementing that frontend in a lightweight JS-minimalist version. But of course, unless I ship my machine to the users, not really. Sad state of affairs.
Nonetheless, I'm really impressed with what's included in the HTML spec nowadays! I haven't kept-up with developments in the spec since I read all about XHTML in high school. I ought to take some time every now and then to see what's changed though, again, browser compatibility is a PITA today as it was back in high school.
Mind that input + datalist is the HTML equivalent of the Windows combobox, once generally regarded as the worst UI element ever. (This was enjoying meme status in usability related articles and write-ups. So probably not a recommendation.)
The general consensus used to be that questions should be either closed (i.e., all the knowledge is disclosed in the interface) or open (any in-between doesn't help to organinze and conceptionalize thought) and that UI elements should signal this appropriately. Now, with autocomplete, there's a use case for this. But there seem to be two types of users, those who make ready use of this and those who ignore it completely, maybe hinting at the question being still open.
(We may observe how the implementation of datalist reflects this: it's still a simple textbox, i.e. input element, and the list is attached as an add-on, rather than being a list type of its own. It's not a list standing on its own, but an enhancement to the input field. So, rather don't use it as a control element for lists?)
PS: The point was really that, if you were to google "worst interface element", you got loads of articles about the combobox.
>What if there’s a bunch of options, but for [reasons] we don’t want a user to be able to select a subset of them? Let’s add the disabled attribute to an optgroup
Seems broken in mobile safari, not actually disabled I can still select the disabled items.
Came here to mention the same thing. Very well be on me, tho. I’m using the Brave browser (is it safari-powered?) and on iOS 18.7.9, which is the newest my old iPhone X supports.
This is the kind of thing I struggle with on using native HtML for more than the basics. Even if you do enough reading and have enough confidence to write an article like this the comments end up with quirks, limitations, or notes on lack of support about different browser+device combos.
Div soup is probably a bit far in the opposite direction, but even then it's at least pretty consistent and apparent what the quirks and limitations are because it aligns with what you or the framework wrote much more consistently.
When I first had to use XML, I had to learn the XML spec and output it manually - serialization libraries didn’t really exist yet. I’ve since seen generation of juniors come up through the ranks using XML as an interchange format (and then JSON) without ever learning it fully. It was fine, and nothing terrible happened.
I’ve seen AJAX go from the hot new thing to people not knowing what it stood for, to now most people not even recognizing the term. AJAX didn’t die; it became so common we don’t need a word for it anymore.
Kind of like JQuery. I know why it was such an incredible library and am happy no new devs I work with (a) know what it is (b) understand why it was necessary.
Thank god the underlying language, libraries, and browser support have moved forward. And IE6 is dead. God, what a nightmare.
I’m aware of the entire progression, and objectively I’ve seen juniors come up without knowing “the old ways” at all. I’m not sure it’s a problem, but I also can’t quite wrap my head around the way they understand systems.
For example the HTML approach to style parts of a control is to use pseudoclasses. Sometimes the selectors are different across browsers! Then you have to test across browsers because who knows if it will actually work correctly.
React is not just easier it's more dependable. If I make something with React and some divs I know it's going to work the same in all browsers.
For example, Blink/Webkit allow <meter> and <progress> to be styled. Firefox does not support those pseudoclasses so you can't style those elements cross browser.
If I build a meter or progress bar in React, I can easily style it and because it uses divs and not wonky pseudoclasses then it looks the same in every browser.
Good stuff, except don't get too excited about `datalist`. It just doesn't have enough hooks to be actually useful for anything other than a little prototype.
I've had problems with <datalist> not showing when the input is misspelled, or when none of the <options> strictly begin with the input. I gave up and used an <ol> instead.
The neat thing about HTML is that it's a living standard and anyone can contribute. Old bugs get corrected all the time simply because it annoyed a certain person enough for them to push a fix through the standards process.
Unfortunately, it could be around a decade before all three major browsers finally implement the standard, and the fix might not be quite as clean as you originally imagined.
The reason is that there are lots of webpage authors, lots of pages that use old standards and very few browser implementations. That made the browsers carry the burden of making it all work right for everyone.
HTML linters actually help distinguish things like that? I'm curious if there are any linters out there that can enforce this kind of semantic tag selection.
SuperHTML validates not only syntax but also element nesting and attribute values. No other language server implements the full HTML spec in its validation code.
Enforce semantic tags? HTML is first and foremost meant for authors to get creative. Enforcing one tag over another doesn't make sense to me. Accessibility yes, but there are plenty of constraints already.
Because for the user experience, it is identical to <ul>. Use <menu> if it helps you to understand your code but in the browser's accessibility tree and in all other respects, it's just an unordered list.
Conveying that something is a list of actions requires adding ARIA attributes. The article mentions `role=menu` but that's not enough, each item also needs the `menuitem` role. The WAI Authoring Practices Guide explains the roles and interaction expectations; don't copy their coded examples and definitely don't use the roles for navigation menus.
<ruby> is going to be featured in my next article: You don't know HTML…Semantics.
I'm debating whether that one will be one or two articles because I'm going to be covering everything from <ruby>, <bdi>, <bdo> all the way through <var>, <kbd>, <samp>, <cite>, and <q>.
After that one, I'll probably have something like, "You don't know HTML interactions" or something to cover <dialog>, <popover>, and the Invoker API.
- do you understand that most of us got 10000+ bookmarks and it would be really really handy if you could make a single page on your website that lists every post every written without the description or the entire article on it?
Good for them. I build my website around topics. If you just want a raw list of everything I've written, that's the sitemap. Otherwise, just browse by topics or even the tags on the posts.
And yet, no native select + search combined, which is a very common kind of list. The datalist is basically unusable, because you don't know any of the options.
tl;dr: You _do_ know HTML lists, they're basicaly like they used to be 20 years ago. But there are HTML form controls which are list-like and this will tell you about them: <select> and <datalist> which have <option> elements and <menu> which has <li> elements.
It's a nice read, not very long and you can kind of leisurely skim it.
I'm not quite sure what you mean about that… I do have a disclaimer in the sidebar that makes it clear that I'm not using AI — but that's solely so that people can appreciate that I put actual effort into writing it.
Somehow I'm still in the mode where I'm surprised where it is, rather than when it isn't, but yeah it's annoyingly often. Do you come across it so much that it's your default expectation now?
I've looked at lists from both sides now
From give and take and still somehow
It's HTML lists' illusions I recall
I really don't know HTML lists at all