• You are currently browsing the archives for the General category.

  • Archive for the ‘General’ Category

    All things open talk: The ES6 Conundrum (slides/screencast/links)

    Tuesday, October 20th, 2015

    I just delivered a talk on JavaScript and ES6 at All things Open in Raleigh, North Carolina.

    This is just a quick post to give you all the content and links I talked about.

    Here’s the slidedeck on Slideshare

    And the screencast of the talk on YouTube

    Links I mentioned:

    Fun with CSS colour names

    Wednesday, October 14th, 2015

    This morning Ars Technica had a wonderful article on CSS colour names titled ““Tomato” versus “#FF6347”—the tragicomic history of CSS color names“. It made me look again into the wonderful world of CSS colour names and create an interactive demo showing them when you roll over the colour swatches.

    Building up on this, I created a small game, that allows you to train your knowledge of colours and their names.


    (The colours in the game don’t change, this is a GIF issue…)

    The source code is on GitHub, and it is pretty simple to create these things, once you have the dataset.

    There were some fun exercises in there, like how to sort the colours by lightness (split the values each 2 characters, convert to decimal, push into array, sort it) and creating an array_shuffle in JS (hey, PHP has it).

    The game keeps your score in local storage and should work fine on mobile – it does on my Huawei Honor.

    16 Questions you need to answer before you give a conference talk

    Tuesday, October 13th, 2015

    When it comes to giving a talk at a conference the thing people freak out the most about is the delivery. Being in front of a large audience on stage is scary and for many people unthinkable.


    I don’t want to discourage anyone to do this – it is amazing and it feels great to inspire people. The good news is that by covering the things here you will go on stage with the utmost confidence and you will dazzle.

    I wanted to note down the things people don’t consider about presenting at conferences. There is no shortage of posts claiming that evangelism is “only presenting at conferences”. Furthermore it is deemed only worth-while when done by “real developers who work on the products”. This is the perfect scenario, of course. Before you judge “just presenting” as a simple task consider the following questions. If you are a professional presenter and evangelist you need to have them covered. More importantly, consider the time needed to do that work and how you would fit it into your daily job of delivering code.

    1. 1) Do you know the topic well enough?
    2. 2) Are you sure about your facts?
    3. 3) Are you aware of the audience?
    4. 4) What’s your story line? How do you package the idea?
    5. 5) Where are the materials you talk about?
    6. 6) Are you sure you can release the talk the way you wrote it?
    7. 7) When are the materials due?
    8. 8) What does the conference need from you?
    9. 9) How do you get to the event?
    10. 10) Do you have all you need? Is everything going to be fine while you’re gone?
    11. 11) Who pays what – how do you get your money back?
    12. 12) Can you afford the time? Do you need to extend your trip to make it worth while?
    13. 13) Have you prepared for a presentation in the conference environment?
    14. 14) How do you measure if this was a success?
    15. 15) How do you make this re-usable for your company?
    16. 16) Are you ready to deal with the follow-up?

    1) Do you know the topic well enough?

    If you talk about your own product, this is easy. It is also easy to be useless. Writing a demo for a talk that can’t fail is cheating. It is also hard to repeat for the audience. It is a theoretical exercise, and not a feat of delivery. Writing a product in a real work environment means dealing with other people’s demands and issues. It also means you have to re-think what you do a lot, and that makes for better products. How you built your product does not make it a best practice. It worked for you. OK, but is that repeatable by your audience or can they learn from you approach?

    To give a great talk, you need to do a lot of homework:

    • you need to read what the competition did,
    • learn what is applicable,
    • you need to understand how the topic you cover can be beneficial for the audience and
    • you need to do research about the necessary environment of your talk topic and issues people may run into when they try to repeat what you did.

    2) Are you sure about your facts?

    It is easy to make grandiose statements and wrap them in the right rhetoric to be exciting. It is also easy to cause a lot of trouble with those. If you make a promise on stage, make sure it is yours to fulfill. You don’t want to get your colleagues into trouble or delivery stress by over-promising.

    You are likely to present to an audience who know their stuff and are happy to find holes in your argumentation. Therefore you need to do your homework. Check your facts, keep them up-to-date and don’t repeat truisms of the past.

    Get the newest information, and verify that it is fact before adding it to your talk. This also means checking various sources and cross-referencing them. Legwork, research.

    Work with your colleagues who will need to deliver what you talk about and maintain it in the future. Ensure they are up to the task. Remember: you are not likely to be the maintainer, so delegate. And delegation means you need to give others a heads-up what is coming their way.

    3) Are you aware of the audience?

    Your job is to educate and entertain the audience of the conference. To achieve this, you need to cater your talk to the audience. Therefore you need to understand them before you go forward. For this, you need to follow some steps:

    Get information about the audience from the conference organisers:

    • How big is the audience?
    • When is your talk – a talk at the end of the day is harder to take in than one in the morning.
    • What is their experience level – you write different materials for experts than for novices. Peer pressure dictates that everyone tells you they are experts. They might still not understand what you do unless you explain it well.
    • What is the language of the audience? Are they native speakers of your language or do you need to cater for misunderstandings? Do your pop references and jokes make sense in that country, or are they offensive or confusing? If there is live translation at the event you will have to be slower and pause for the translators to catch up. You will also need to deliver your slides up-front and have a list of technical words that shouldn’t be translated. Your slide deck also needs to be printable for translators to use.

    Then think about what you’d like to get out of your talk:

    • Try to think like your audience – what excites a group of designers is not the same a group of developers or project managers need
    • Look at the rest of the line-up. Is your talk unique or will you clash or repeat with another talk at the same event?

    4) What’s your story line? How do you package the idea?

    A presentation is nothing without a story. Much like a movie you need to have to have an introduction, a climax and a conclusion. Intersperse this with some anectodes and real life comparisons and you have something people can enjoy and learn from. Add some humour and some open questions to engage and encourage. How do you do that? What fits this talk and this audience?

    5) Where are the materials you talk about?

    If you want the audience to repeat what you talk about you need to make sure your materials are available.

    • Your code examples need to be for example on GitHub, need to work and need documentation.
    • If you talk about a product of your company make sure the resource isn’t going away by the time you give your talk.
    • Your slides should be on the web somewhere as people always ask for them right after your talk.

    6) Are you sure you can release the talk the way you wrote it?

    It is simple to pretend that we are a cool crowd and everyone gets a good geek joke. It is also easy to offend people and cause a Twitter storm and an ugly aftermath in the tech press.

    It is also easy to get into legal trouble for bad-mouthing the competition or using media nilly-willy. Remember one thing: fair use is a myth and not applicable internationally. Any copyrighted material you use in your talk can become a problem. The simplest way to work around that is to only use creative commons licensed materials.

    That might mean you don’t use the cool animated GIF of the latest TV show. And that might be a good thing. Do you know if the audience knows about this show and gets your reference? Thinking internationally and questioning your cultural bias can be the difference between inspiring and confusing. Or frustrating. If you talk about great products that aren’t available in the country you present. Don’t write your talk from your perspective. Think what the audience can do with your material and if they can understand it.

    7) When are the materials due?

    There are quite a few things that affect the time you have to prepare your presentation:

    • Your company might have a policy to have your slides reviewed by legal and marketing. This sounds terrible and smacks of censorship. But it can save your arse. It might also make you aware of things you can hint at that aren’t public knowledge yet.
    • The conference might need your talks upfront. Every conference wants at least an outline and your speaker bio to publish on their web site.
    • Do you have enough time for research, creation and designing your slides before you travel? Can you upload your deck to the web in case your machine breaks down?

    8) What does the conference need from you?

    Depending on what the conference does for you, they also want you to help them. That can include:

    • some promotion on your social media channels
    • information about your travel and accomodation
    • VISA requirements and signing releases about filming and material distribution rights
    • invoices for expenses you have on their behalf
    • information on your availability for speaker dinners, event parties or other side activities of the main event

    This needs time allocated to it. In general you can say a one day conference will mean you’re out for three.

    9) How do you get to the event?

    Traveling is the biggest unknown in your journey to the stage. All kind of things can go wrong. You want to make sure you book the right flights, hotels and have a base close to the event. All this costs money, and you will find conference organisers and your company try to cut down on cost whenever they can. So be prepared for some inconvenience.

    Booking and validating your travel adds and extra two days to your conference planning. Getting to and from your home to the event can be a packed and stressful journey. Try to avoid getting to the event stressed, you need to concentrate on what you are there for. Add two buffer days before and after the event at least.

    Booking your own travel is great. You are not at the mercy of people spelling your name wrong or asking you for all kind of information like your passport and date of birth. But it also means you need to pay for it in some way or another and you want that money back. Finding a relaxed and affordable schedule is a big task, and something you shouldn’t take too lightly.

    10) Do you have all you need? Is everything going to be fine while you’re gone?

    You are going to be out for a while. Both from work and your home. Make sure that in your absence you have people in place that can do the job you normally do. Make sure you covered all the needs like passport and visa issues and you know everything about the place you go to.

    Prepare to get sick and have medication with you. It can happen and it should not be the end of the trip. Stay healthy, bring some safe food and plan for time to work out in between sitting cramped on planes and in cars.

    Do you know how to get to the hotel and around the city you present in? Do you speak the language? Is it safe? Is there someone to look after your home when you’re gone? Prepare for things going wrong and you having to stay longer. Planes and trains and automobiles fail all the time.

    11) Who pays what – how do you get your money back?

    Conference participation costs money. You need to pay for travel, accomodation, food, wireless, mobile roaming costs and many more unknowns. Make sure you get as much paid for you as possible. Many conference organisers will tell you that you can pay for things and keep receipts. That means you will have to spend quite some time with paperwork and chasing your money. The same applies to company expense procedures. You need to deal with this as early as possible. The longer you wait, the harder it gets.

    12) Can you afford the time? Do you need to extend your trip to make it worth while?

    A local event is pretty easy to sell to your company. Flying somewhere else and having the both the cost of money and time involved is harder. Even when the conference organiser pays – it means you are out of the office and not available for your normal duty. One way to add value for your company is to add meetings with local clients and press. These need to be organised and planned. So ensure you cater for that.

    13) Have you prepared for a presentation in the conference environment?

    It is great to use online editors to write your talk. It means people can access your slides and materials. It also means you are independent of your computer – which can and will behave oddly as soon as you are on stage. Online materials are much less useful once you are offline on stage. Conference wireless is anything but reliable. Make sure you are not dependent on a good connection. Ask about the available resolution of the conference projection equipment. Don’t expect sound to be available. And above all – bring your own connectors and power cables and converters.

    14) How do you measure if this was a success?

    Your company gave you time and money to go to a conference and give a talk. How do you make this worth their while? You have to show something on your return. Make sure you measure the feedback your talk got. See if you can talk to people at the event your company considers important. Collect all this during the event and analyse and compact it as soon as you can. This sounds simple, but it is tough work to analyse sentiment. A Twitter feed of a conference is pretty noisy.

    15) How do you make this re-usable for your company?

    If you work for a larger company, they expect of you as an evangelist to make your materials available for others. A lot of companies believe in reusable slide decks – for better or worse. Prepare a deck covering your topic that is highly annotated with delivery notes. Prepare to present this to your company. Whilst hardly anything is reusable, you are expected to make that happen.

    16) Are you ready to deal with the follow-up?

    After the conference you have to answer emails, contact requests and collect and note down your leads. Most companies expect a conference report of some sort. Many expect you to do some internal presentation to debrief you. What you did costs a lot of time and money and you should be prepared to prove your worth.

    You’ll get more requests about your talk, the products you covered and people will ask you to speak at other events. And thus the cycle starts over.


    That’s just a few of the things you have to consider as a presenter at conferences. I didn’t deal with stress, jet lag, demands, loneliness and other mental influences here. Next time you claim that people “talk instead of being a real coder” consider if what you’re saying is valid criticism or sounds a bit like “bro, do you even lift?”. Of course there are flim-flam artists and thinly veiled sales people calling themselves evangelists out there. But that doesn’t mean you should consider them the norm.

    Of impostor syndrome and running in circles (part 3)

    Wednesday, September 30th, 2015

    These are the notes of my talk at SmartWebConf in Romania. Part 1 covered how Impostor Syndrome cripples us in using what we hear about at conferences. It covered how our training and onboarding focuses on coding instead of human traits. In Part 2 I showed how many great things browsers do for us we don’t seem to appreciate. In this final part I’ll explain why this is and why it is a bad idea. This here is a call to action to make yourself feel better. And to get more involved without feeling inferior to others.

    This is part 3 of 3.

    Part 2 of this series ended with the explanation that JavaScript is not fault tolerant, and yet we rely on it for almost everything we do. The reason is that we want to control the outcome of our work. It feels dangerous to rely on a browser to do our work for us. It feels great to be in full control. We feel powerful being able to tweak things to the tiniest detail.

    JavaScript is the duct-tape of the web

    There is no doubt that JavaScript is the duct-tape of the web: you can fix everything with it. It is a programming language and not a descriptive language or markup. We have all kind of logical constructs to write our solutions in. This is important. We seem to crave programmatic access to the things we work with. That explains the rise of CSS preprocessors like Sass. These turn CSS into JavaScript. Lately, PostCSS even goes further in merging these languages and ideas. We like detailed access. At the same time we complain about complexity.

    No matter what we do – the problem remains that on the client side JavaScript is unreliable. Because it is fault intolerant. Any single error – even those not caused by you – result in our end users getting an empty screen instead of the solution they came for. There are many ways JavaScript can fail. Stuart Langridge maintains a great flow chart on that called “Everyone has JavaScript, right?“.

    There is a bigger issue with fixing browser issues with JavaScript. It makes you responsible and accountable for things browser do. You put it onto yourself to fix the web, now it is your job to keep doing that – for ever, and ever and ever…

    Taking over things like page rendering, CSS support and page loading with JavaScript feels good as it fixes issues. Instead of a slow page load we can show a long spinner. This makes us feel good, but doesn’t help our end users much. Especially when the spinner has no timeout error case – like browser loading has.

    Fixing a problem with JavaScript is fun. It looks simple enough and it removes an unknown browser support issue. It allows us to concentrate on building bigger and better things. And we don’t have to worry about browser issues.

    It is an inspiring feeling to be the person who solved a web-wide issue. It boosts our ego to see that people rely on our brains to solve issues for them. It is great to see them become more effective and faster and free to build the next Facebook.

    It gets less amazing when you want to move on and do something else. And when people have outrageous demands or abuse your system. Remy Sharp lately released a series of honest and important blog posts on that matter. “The toxic side of free” is a great and terrifying read.

    Publishing something new in JavaScript as “open source” is easy these days. GitHub made it more or less a one step process. And we get a free wiki, issue tracker and contribution process with it to boot. That, of course, doesn’t mean we can make this much more complex if we wanted to. And we do as Eric Douglas explains.

    open source is free as in puppy

    Releasing software or solutions as open source is not the same as making it available for free. It is the start of a long conversation with users and contributors. And that comes with all the drama and confusion that is human interaction. Open Source is free as in puppy. It comes with responsibilities. Doing it wrong results in a badly behaving product and community around it.

    Help stop people falling off the bleeding edge

    300 cliff

    If you embrace the idea that open source and publishing on the web is a team effort, you realise that there is no need to be on the bleeding edge. On the opposite – any “out there” idea needs a group of peers to review and use it to get data on how sensible the idea really is. We tend to skip that part all too often. Instead of giving feedback or contributing to a solution we discard it and build our own. This means all we have to do is to deal with code and not people. It also means we pile on to the already unloved and unused “amazing solutions” for problems of the past that litter the web.

    The average web page is 2MB with over 100 http requests. The bulk of this is images, but there is also a lot of JS and CSS magical solutions in the mix.

    If we consider that the next growth of the internet is not in the countries we are in, but in emerging places with shaky connectivity, our course of action should be clear: clean up the web.

    Of course we need to innovate and enhance our web technology stack. At the same time it is important to understand that the web is an unprecedented software environment. It is not only about what we put in, it is also about what we can’t afford to lose. And the biggest part of this is universal access. That also means it needs to remain easy to turn from consumer into creator on the web.

    If you watch talks about internet usage in emerging countries, you’ll learn about amazing numbers and growth predictions.

    You also learn about us not being able to control what end users see. Many of our JS solutions will get stripped out. Many of our beautiful, crafted pictures optimised into a blurry mess. And that’s great. It means the users of the web of tomorrow are as empowered as we were when we stood up and fought against browser monopolies.

    So there you have it: you don’t have to be the inventor of the next NPM module to solve all our issues. You can be, but it shouldn’t make you feel bad that you’re not quite interested in doing so. As Bill Watterson of Calvin and Hobbes fame put it:

    We all have different desires and needs, but if we don’t discover what we want from ourselves and what we stand for, we will live passively and unfulfilled.

    So, be active. Don’t feel intimidated by how clever other people appear to be. Don’t be discouraged if you don’t get thousands of followers and GitHub stars. Find what you can do, how you can help the merging of bleeding edge technologies and what goes into our products. Above all – help the web get leaner and simpler again. This used to be a playground for us all – not only for the kids with the fancy toys.

    You do that by talking to the messy kids. Those who build too complex and big solutions for simple problems. Those doing that because clever people told them they have to use all these tools to build them. The people on the bleeding edge are too busy to do that. You can. And I promise, by taking up teaching you end up learning.

    Of impostor syndrome and running in circles (part 2)

    Monday, September 28th, 2015

    These are the notes of my talk at SmartWebConf in Romania. Part 1 covered how Impostor Syndrome cripples us in using what we hear about at conferences. It also covered how our training and onboarding focuses on coding. And how it lacks in social skills and individuality. This post talks about the current state of affairs. We have a lot of great stuff to play with but instead of using it we always chase the next.

    This is part 2 of 3.

    Lunch eaten by native: news at 11

    When reading about the state of the web there is no lack of doom and gloom posts. Native development is often quoted as “eating our lunch”. Native-only interaction models are sold to us as things “people use these days”. Many of them are dependent on hardware or protected by patents. But they look amazing and in comparison the web seems to fall behind.

    The web doesn’t need to compete everywhere

    This is true, but it also not surprising. Flash showed many things that are possible that HTML/CSS/JS couldn’t do. Most of these were interesting experiments. They looked like a grand idea at the time. And they went away without an outcry of users. What a native environment have and what we do on the web is a comparison the web can’t win. And it shouldn’t try to.

    The web per definition is independent of hardware and interaction model. Native environments aren’t – on the contrary. Success on native is about strict control. You control the interaction, the distribution and what the user can and can’t see. You can lock out users and not let them get to the next level. Unless they pay for it or buy the next version of your app or OS. The web is a medium that puts the user in control. Native apps and environments do not. They give users an easy to digest experience. An experience controlled by commercial ideas and company goals. Yes, the experience is beautiful in a lot of cases. But all you get is a perishable good. The maintainer of the app controls what stays in older versions and when you have to pay the next version. The maintainers of the OS dictate what an app can and can not do. Any app can close down and take your data with it. This is much harder on the web as data gets archived and distributed.

    The web’s not cool anymore – and that’s OK

    Evolution happens and we are seeing this right now. Browsers on desktop machines are not the end-all of human-computer interaction. That is one way of consuming and contributing to the web. The web is ubiquitous now. That means it is not as exciting for people as it was for us when we discovered and formed it. It is plumbing. How much do you know about the electricity and water grid that feeds your house? You never cared to learn about this – and this is exactly how people feel about the web now.

    This doesn’t mean the web is dead – it just means it is something people use. So our job should be to make that experience as easy as possible. We need to provide a good service people can trust and rely on. Our aim should be reliability, not flights of fancy.

    It is interesting to go back to the promises HTML5 gave us. Back when it was the big hype and replacement for Flash/Flex. When you do this, you’ll find a lot of great things that we have now without realising them. We complained when they didn’t work and now that we have them – nobody seems to use them.

    Re-visiting forms

    Take forms for example. You can see the demos I’m about to show here on GitHub.

    When it comes down to it, most “apps” in their basic form are just this: forms. You enter data, you get data back. Games are the exception to this, but they are only a small part of what we use the web for.

    When I started as a web developer forms meant you entered some data. Then you submitted the form and you got an error message telling you what fields you forgot and what you did wrong.

    <form action="/cgi-bin/formmail.pl">
      <ul class="error">
        <li>There were some errors:
            <li><a href="#name">Name is required</a></li>
            <li><a href="#birthday">Birthday needs to 
              be in the format of DD/MM/YYYY</a></li>
            <li><a href="#phone">Phone can't have 
              any characters but 0-9</a></li>
            <li><a href="#age">Age needs to be 
              a number</a></li>
      <p><label for="name">Contact Name *</label>
         <input type="text" id="name" name="name"></p>
      <p><label for="bday">Birthday</label>
         <input type="text" id="bday" name="bday"></p>
      <p><label for="lcolour">Label Colour</label>
         <input type="text" id="lcolour" name="lcolour"></p>
      <p><label for="phone">Phone</label>
         <input type="text" id="phone" name="phone"></p>
      <p><label for="age">Age</label>
         <input type="text" id="age" name="age"></p>
      <p class="sendoff">
        <input type="submit" value="add to contacts">

    form with error links

    This doesn’t look much, but let’s just remember a few things here:

    • Using labels we make this form available to all kind of users independent of ability
    • You create a larger hit target for mobile users. A radio button with a label next to it means users can tap the word instead of trying to hit the small round interface element.
    • As you use IDs to link labels and elements (unless you nest one in the other), you also have a free target to link to in your error links
    • With a submit button you enable user to either hit the button or press enter to send the form. If you use your keyboard, that’s a pretty natural way of ending the annoying data entry part.

    Nothing ground-breaking, I admit, but a lot of useful functionality. Functionality you’d have to simulate if you did it all with SPANs and DIVs. And all this without a single line of JavaScript.

    Enter JavaScript

    Then we got JavaScript. This enabled us to create higher fidelity forms. Forms that tell the user when something went wrong before submitting. No more uneccesary page reloads. We started to build richer interaction models like forms with optional fields depending on the content of others. In my 2006 book Beginning JavaScript with DOM Scripting in Ajax I had a whole chapter dedicated to forms (code examples are here). All of these enhancements had the problem that when JavaScript for some reason or another didn’t work, the form still was happily submitting data to the server. That meant and still means that you have to validate on the server in addition to relying on client-side validation. Client side validation is a nice-to-have, not a security measure.

    Enter HTML5 and browser convenience features

    HTML5 supercharged forms. One amazing thing is the required attribute we can put on any form field to make it mandatory and stop the form from submitting. We can define patterns for validation and we have higher fidelity form types that render as use-case specific widgets. If a browser doesn’t support those, all the end user gets is an input field. No harm done, as they can just type the content.

    In addition to this, browsers added conveniences for users. Browsers remember content for aptly named and typed input elements so you don’t have to type in your telephone number repeatedly. This gives us quite an incredible user experience. A feature we fail to value as it appears so obvious.

    Take this example.

    <form action="/cgi-bin/formmail.pl">
      <p><label for="name">Contact Name *</label>
         <input type="text" required id="name" name="name"></p>
      <p><label for="bday">Birthday</label>
         <input type="date" id="bday" name="bday" 
      <p><label for="lcolour">Label Colour</label>
         <input type="color" id="lcolour" name="lcolour"></p>
      <p><label for="phone">Phone</label>
         <input type="tel" id="phone" name="phone"></p>
      <p><label for="age">Age</label>
         <input type="number" id="age" name="age"></p>
      <p class="sendoff">
        <input type="submit" value="add to contacts">

    animation showing different form elements and auto-filling by browsers

    There’s a lot of cool stuff happening here:

    • I can’t send the form without entering a contact name. This is what the required attribute does. No JavaScript needed here. You even can rename the error message or intercept it.
    • The birthday date field has a placeholder telling the user what format is expected. You can type a date in or use the arrows up and down to enter it. The form automatically realises that there is no 13th month and that some months have less than 31 days. Other browsers even give you a full calendar popup.
    • The colour picker is just that – a visual, high-fidelity colour picker (yes, I keep typing this “wrong”)
    • The tel and number types do not only limit the allowed characters to use, but also switch to the appropriate on-screen keyboards on mobile devices.
    • Any erroneous field gets a red border around it – I can’t even remember how many times I had to code this in JavaScript. This is even style-able with a selector.

    That’s a lot of great interaction we get for free. What about cutting down on the display of data to make the best of limited space we have?

    Originally, this is what we had select boxes for, which render well, but are not fun to use. As someone living in England and having to wonder if it is “England”, “Great Britain” or “United Kingdom” in a massive list of countries, I know exactly how that feels. Especially on small devices on touch/stylus devices they can be very annoying.

    <form action="/cgi-bin/formmail.pl">
      <label for="lang">Language</label>
      <select id="lang" name="lang">
    <p class="sendoff">
      <input type="submit" value="add to contacts">

    scrolling through a select box

    However, as someone who uses the keyboard to navigate through forms, I learned early enough that these days select boxes have become more intelligent. Instead of having to scroll through them by clicking the tiny arrows or using the arrow keys you can start typing the first letter of the option you want to choose. That way you can select much faster.

    typing in a select box

    This only works with words beginning with the letter sequence you type. A proper autocomplete should also match character sequences in the middle of an option. For this, HTML5 has a new element called datalist.

    <form action="/cgi-bin/formmail.pl">
        <label for="lang">Language</label>
        <input type="text" name="lang" id="lang" list="languages">
        <datalist id="languages">
      <p class="sendoff">
        <input type="submit" value="add to contacts">

    This one extends an input element with a list attribute and works like you expect it to:

    datalist autocomplete example

    There is an interesting concept here. Instead of making the select box have the same feature and roll it up into a combo box that exists in other UI libraries, the working group of HTML5 chose to enhance an input element. This is consistent with the other new input types.

    However, it feels odd that for browsers that don’t support the datalist element all this content in the page would be useless. Jeremy Keith thought the same and came up with a pattern that allows for a select element in older browsers and a datalist in newer ones:

    <form action="/cgi-bin/formmail.pl">
        <label for="lang">Language</label>
        <datalist id="languages">
        <select name="lang">
        <div>or specify: </div>
        <input type="text" name="lang" id="lang" list="languages">
      <p class="sendoff">
        <input type="submit" value="add to contacts">

    This works as a datalist in HTML5 compliant browsers.

    datalist autocomplete example working

    In older browsers, you get a sensible fallback, re-using all the option elements that are in the document.

    datalist autocomplete example failing and falling back to a select box

    This is not witchcraft, but is based on a firm understanding of how HTML and CSS work. Both these are fault tolerant. This means if a mistake happens, it gets skipped and the rest of the document or style sheet keeps getting applied.

    In this case, older browsers don’t know what a datalist is. All they see is a select box and an input element as browsers render content of unknown elements. The unknown list attribute on the input element isn’t understood, so the browser skips that, too.

    HTML5 browsers see a datalist element. Per standard, all this can include are option elements. That’s why neither the select, nor the input and the text above it get rendered. They are not valid, so the browser removes them. Everybody wins.

    A craving for control

    Browsers and the standards they implement are full of clever and beautiful things like that these days. And we’ve loudly and angrily demanded to have them when they got defined. We tested, we complained, we showed what needed to be done to make the tomorrow work today and then we forgot about it. And we moved on to chase the next innovation.

    How come that repeatedly happens? Why don’t we at some point stop and see how much great toys we have to play with? It is pretty simple: control.

    We love to be in control and we like to call the shots. That’s why we continuously try to style form elements and create our own sliders, scroll bars and dropdown boxes. That’s why we use non-support by a few outdated browsers of a standard as an excuse to discard it completely and write a JavaScript solution instead. We don’t have time to wait for browsers to get their act together, so it is up to us to save the day. Well, no, it isn’t.

    Just because you can do everything with JavaScript, doesn’t mean that you should do it. We invented HTML5 as the successor and replacement of XHTML as it had one flaw: a single wrong encoding or nesting of elements and the document wouldn’t render. End users would be punished for our mistakes. That’s why HTML5 is fault tolerant.

    JavaScript is not. Any mistake that happens means the end user looks at an endless spinner or an empty page. This isn’t innovation, this is building on a flaky foundation. And whilst we do that, we forgot to re-visit the foundation we have in browsers and standards support. This is a good time to do that. You’d be surprised how many cool things you’ll find you only thought possible by using a JavaScript UI framework.

    But more on that in part 3 of this post.