Make your browser game work on phones
To make a browser game work on phones, add a viewport tag, take touch or pointer input without letting the page scroll, start sound only after the first tap, offer fullscreen from a tap, fit both portrait and landscape and test the hosted link on a real phone. Then answer Yes, it works on phones when you list it on Foundplay for free, and select Mobile Friendly on itch.io if it's there too.
Checked November 22, 2026. Written by Foundplay, a game discovery platform for free browser games.
Copy these to start
<meta name="viewport" content="width=device-width">canvas { touch-action: none; }let audio;
document.querySelector("#start").addEventListener("click", () => {
audio ??= new AudioContext();
if (audio.state === "suspended") audio.resume();
// Start the game here.
});What to get right
| Part | What to do | Watch for |
|---|---|---|
| Viewport tagSources: MDN: viewport meta tagChecked November 22, 2026. | Put <meta name="viewport" content="width=device-width"> in the page's head, so the phone sizes the page to its screen. | Add initial-scale=1 if the page shrinks because something is wider than the screen. Leave zoom on: user-scalable=no stops people with low vision from zooming, and MDN notes iOS 10 and later ignore it by default. |
| Touch inputSources: MDN: Mobile touch controls, MDN: Pointer eventsChecked November 22, 2026. | Listen for touchstart, touchmove, touchend and touchcancel, or use pointer events, one set of events for mouse, pen and touch. A game played with keys needs buttons on the screen too. | Call preventDefault() in the touch handlers, or the canvas is dragged around the page and scroll bars show. With pointer events, set touch-action: none on the game's element to turn off the browser's own panning and zooming there. |
| Sound after a tapSources: MDN: Web Audio best practices, MDN: User activation, MDN: Autoplay guideChecked November 22, 2026, and again November 23, 2026. | Create or resume the AudioContext inside the click handler of a Start button, the user gesture MDN names. | An AudioContext made before any tap starts suspended and stays silent until resume(). Don't use pointerdown for this: MDN counts it as the player's gesture only for a mouse, while a finger's tap counts on pointerup and touchend. Sound that starts before the player has touched the page is generally blocked. |
| FullscreenSources: MDN: Fullscreen APIChecked November 22, 2026. | Call requestFullscreen() on the game's element from a tap, such as a Fullscreen button. | It works only in answer to the player's tap or click. MDN marks it as not working in some widely used browsers, so the game has to fit the screen without it too. |
| Screen orientationSources: MDN: Screen Orientation API, MDN: lock()Checked November 22, 2026. | Make the game fit both portrait and landscape, or tell the player which way to hold the phone. screen.orientation tells you which way the screen is turned. | screen.orientation.lock() typically works only on phones and only in fullscreen, and MDN marks it as not working in some widely used browsers. Catch its error and carry on. |
| Test on a real phoneSources: Launch checklistChecked November 22, 2026. | Open the hosted link on a phone over mobile data, in a private window. Try an iPhone and an Android phone, one of them a few years old if you can. | Play it in portrait and landscape, and check that the sound starts and the page doesn't scroll while you play. |
| FoundplaySources: Submit a gameChecked November 22, 2026. | When you list the game, answer Yes, it works on phones under Does it work on phones? | Phones show phone-friendly games first, so this decides where yours shows on a phone. |
| itch.ioSources: HTML5 gamesChecked November 22, 2026. | Select the Mobile Friendly option in the game's embed settings. | On a phone, itch.io opens the game with Click to launch in fullscreen. Without the option, players see a warning that the game may not work, and can still try it. |
- What to do
- Put <meta name="viewport" content="width=device-width"> in the page's head, so the phone sizes the page to its screen.
- Watch for
- Add initial-scale=1 if the page shrinks because something is wider than the screen. Leave zoom on: user-scalable=no stops people with low vision from zooming, and MDN notes iOS 10 and later ignore it by default.
Sources: MDN: viewport meta tag
Checked November 22, 2026.
- What to do
- Listen for touchstart, touchmove, touchend and touchcancel, or use pointer events, one set of events for mouse, pen and touch. A game played with keys needs buttons on the screen too.
- Watch for
- Call preventDefault() in the touch handlers, or the canvas is dragged around the page and scroll bars show. With pointer events, set touch-action: none on the game's element to turn off the browser's own panning and zooming there.
Sources: MDN: Mobile touch controls, MDN: Pointer events
Checked November 22, 2026.
- What to do
- Create or resume the AudioContext inside the click handler of a Start button, the user gesture MDN names.
- Watch for
- An AudioContext made before any tap starts suspended and stays silent until resume(). Don't use pointerdown for this: MDN counts it as the player's gesture only for a mouse, while a finger's tap counts on pointerup and touchend. Sound that starts before the player has touched the page is generally blocked.
Sources: MDN: Web Audio best practices, MDN: User activation, MDN: Autoplay guide
Checked November 22, 2026, and again November 23, 2026.
- What to do
- Call requestFullscreen() on the game's element from a tap, such as a Fullscreen button.
- Watch for
- It works only in answer to the player's tap or click. MDN marks it as not working in some widely used browsers, so the game has to fit the screen without it too.
Sources: MDN: Fullscreen API
Checked November 22, 2026.
- What to do
- Make the game fit both portrait and landscape, or tell the player which way to hold the phone. screen.orientation tells you which way the screen is turned.
- Watch for
- screen.orientation.lock() typically works only on phones and only in fullscreen, and MDN marks it as not working in some widely used browsers. Catch its error and carry on.
Sources: MDN: Screen Orientation API, MDN: lock()
Checked November 22, 2026.
- What to do
- Open the hosted link on a phone over mobile data, in a private window. Try an iPhone and an Android phone, one of them a few years old if you can.
- Watch for
- Play it in portrait and landscape, and check that the sound starts and the page doesn't scroll while you play.
Sources: Launch checklist
Checked November 22, 2026.
- What to do
- When you list the game, answer Yes, it works on phones under Does it work on phones?
- Watch for
- Phones show phone-friendly games first, so this decides where yours shows on a phone.
Sources: Submit a game
Checked November 22, 2026.
- What to do
- Select the Mobile Friendly option in the game's embed settings.
- Watch for
- On a phone, itch.io opens the game with Click to launch in fullscreen. Without the option, players see a warning that the game may not work, and can still try it.
Sources: HTML5 games
Checked November 22, 2026.
Questions
- How do I make my HTML5 game work on mobile?
- Add a viewport tag, handle touch or pointer events and call preventDefault() so the page doesn't scroll, start sound in a Start button's click handler, fit portrait and landscape, and test the hosted link on a real phone.
- Why is there no sound in my browser game on a phone?
- Browsers generally block sound that starts before the player has touched the page. An AudioContext made before that starts suspended: create it or call resume() inside a Start button's click handler. A pointerdown handler isn't enough on a phone, because MDN counts pointerdown as the player's gesture only for a mouse.
- How do I stop the page scrolling when players touch my game?
- Call preventDefault() in your touchstart and touchmove handlers. With pointer events, set touch-action: none on the canvas so the browser doesn't pan or zoom there.
- Can I make my browser game fullscreen on a phone?
- Call requestFullscreen() from a tap, such as a Fullscreen button. MDN marks the Fullscreen API as not working in some widely used browsers, so make the game fit the screen without it too.
- How do players on Foundplay know my game works on phones?
- Answer Yes, it works on phones when you list it. Phones show phone-friendly games first. Where to upload your HTML5 game covers the hosts.
More for makers: Where to upload your HTML5 game, Browser game file size limits, Cross-origin isolation for browser games, Make your browser game load faster, Embed a browser game on your site, List your browser game for free, Alternatives to itch.io for browser games and Submit a game to Foundplay.