Thursday, May 31, 2012

HTML5 Multiple Choice Quiz Tutorial

I remember when I started working with HTML5 and I was surprised I couldn't find a decent tutorial for making a simple MCQ quiz. So now that I've gotten more confident with the technology, I've decided to publish my own. Putting together a short quiz is an excellent project for someone starting off with a technology, and it's great for someone crossing over into HTML5 from Flash.

The tutorial is here:

And it includes all the code and artwork you need for the project.

UPDATE: I have produced a simpler version, see here:

and a version with pictures here:

The new versions will work on phone screens too.

UPDATE 2: A version with a varied number of options:



  1. The "simpler version" does not work. Even the example file doesn't work :(

  2. This comment has been removed by the author.

  3. after removing "fileDB();" the code works without error. Good work ! - this has saved my quite a bit of time !

  4. Okay everything works, however, one do I go about adding more options to each question?

    1. I have addressed this here:

  5. Update: I have removed the extra line of code (fillDB()). Please note that when OFFLINE, it will not run in Chrome due to security restrictions. Test it offline in Firefox or IE.

  6. Your example is exactly what I needed to get going - thank you so much - need to expand this into a mulitplayer model... any ideas?

  7. Hey great tutorial ! Thank you so much =)

  8. Hey!

    Great tutorial!
    Just wonder, how would I go about if I wanted to get a random question each time I start a new question session and then store the question away so the same question won't show multiple times?

  9. Hi nearly the same question, less sophisticated : can you explian how we could pick x questions at random in the json file ? Thnaks anyway.

  10. An example where questions are randomised:

    Other questions, please mail me at fbnmail* (replace the * with @). I will help you the best I can.

  11. Nice blog...Very useful information is providing by ur blog. Checkout Great beginning html tutorials Very clear and helpful for beginners.

  12. Great tutorial. I was trying to see if there was a way to highlight the correct answer after a choice has been made?