Browser Gaming

HTML5 Games Explained for Beginners

Illustration of layered browser technologies stacked together

"HTML5 game" is shorthand rather than a precise technical term. It does not mean the game is written in HTML - it means the game uses a particular set of capabilities that modern browsers provide natively.

What is actually in the bundle

CapabilityWhat it providesWhat games use it for
CanvasA drawing surfaceEverything you see in the play area
JavaScriptThe programming languageAll the game logic
requestAnimationFrameFrame schedulingThe main game loop
DOM eventsKeyboard, mouse and touch inputControls
Web AudioSound generation and playbackJumps, coins, collisions
localStoragePer-site storage on your deviceHigh scores and preferences

A game using these is called an HTML5 game. The name stuck because the collection arrived roughly alongside the HTML5 specification, not because HTML itself does much of the work.

What it replaced

Before this, browser games ran in plugins - most prominently Flash. A plugin was separate software the browser handed the page to, with its own security model, its own performance characteristics and its own release cycle. That separation was convenient for developers and a persistent liability for everyone else.

The native capabilities above eventually covered the same ground, and browsers withdrew plugin support. Nothing needs installing now because the browser does all of it itself.

What HTML5 games are good at

  • Starting instantly. A small game is a few hundred kilobytes and is playable in a second or two.
  • Running anywhere. The same page works on a phone, a tablet, a laptop and a desktop with no separate versions.
  • Linking. A game has a URL. You can send someone a game the way you send them an article.
  • Being part of a page. The game sits inside a document, so instructions, controls and explanation can be real text around it.
  • Updating silently. A fix is live on the next page load with nothing for the player to do.

What they are less good at

Honesty is more useful than enthusiasm here.

Large 3D projects
Possible through WebGL, but the browser's memory and loading constraints make big worlds genuinely harder than on a native platform.
Heavy asset loading
Everything arrives over the network. A game with a gigabyte of textures is a poor fit for a format whose main advantage is starting instantly.
Accessibility inside the canvas
A canvas has no structure, so nothing drawn in it can be read by assistive technology. Anything meaningful must exist outside it as real HTML.
Precise low-level control
The browser manages memory and scheduling. For most games this is fine; for anything needing microsecond timing it is not.

Do you need a game engine?

For a small arcade game, no. Every game on this site is written in plain JavaScript with no framework, and the total code for a complete game is a few hundred lines on top of a shared engine we wrote ourselves.

Engines earn their weight on larger projects - complex scenes, many entities, physics, asset pipelines. On a game that draws a few dozen shapes per frame, an engine adds more download weight and complexity than it saves.

Where to start if you want to build one

  1. Get a canvas and draw a rectangleThat is the whole starting point. If you can draw a rectangle and move it, you have the core of a game.
  2. Add a loop with elapsed timeUse requestAnimationFrame, measure the time between frames, and multiply all movement by it. This is the single most important habit.
  3. Add gravity and a jumpTwo numbers and one rule: add gravity to velocity, add velocity to position. The parabola appears on its own.
  4. Add a rectangle overlap testFour comparisons. That is your collision system for most of an arcade game.
  5. Add score and localStorageWrap every storage access in error handling - it can fail, and the game must still work when it does.

Key Takeaways

  • "HTML5 game" names a bundle of native browser capabilities, not a language or a framework.
  • The bundle is Canvas, JavaScript, requestAnimationFrame, DOM events, Web Audio and localStorage.
  • It replaced plugins, which is why nothing needs installing any more.
  • The format excels at instant start, universal reach and being part of a real page.
  • A small arcade game needs no engine at all - a few hundred lines of plain JavaScript is enough.

Frequently Asked Questions

Is HTML5 a programming language?

No. It is a specification for the web platform. The programming in an HTML5 game is JavaScript.

Are HTML5 games slower than native apps?

For small 2D games the difference is irrelevant. For large 3D projects the gap becomes real.

Do I need to know HTML to make one?

Only a little - enough to place a canvas element on a page. The game itself is JavaScript.

Can HTML5 games be sold or monetised?

Yes, commonly through advertising or licensing. This site is intended to be supported by advertising.

Why do some HTML5 games load slowly?

Usually large downloaded assets or advertising scripts loading before the game, rather than anything inherent to the technology.

Play the games this covers

Keep reading

Browser Gaming

How HTML5 Browser Games Work

From URL to playable game in about a second. Here is every step of what happens in between.

Browser Gaming

Canvas Games Explained

A rectangle the browser hands to the game, repainted sixty times a second - and completely opaque to screen readers.