Website publishing
How to Embed an HTML5 Game on Your Website Without Breaking the Layout
The parts of a game iframe explained, a portrait variant, matching games to visitors, and the usual reasons an embed shows blank: CSP, CMS editors, referrer policy.
Pasting an iframe into a page takes a minute. Getting it to look right on a phone, a laptop and an ultrawide monitor takes a little more thought. This guide walks through the parts of a game embed that matter and the mistakes that break it.
Start with the snippet
This is the structure PlayKovo gives you for each game in the free game catalog:
<div style="position:relative;width:100%;aspect-ratio:16/9;overflow:hidden;background:#000;">
<iframe
src="https://playkovo.com/embed/rainbow-run"
title="Rainbow Run on PlayKovo"
style="position:absolute;inset:0;width:100%;height:100%;border:0;"
loading="lazy"
allow="fullscreen; autoplay; gamepad; pointer-lock"
allowfullscreen>
</iframe>
</div>
What each part does
- The wrapper div with
aspect-ratio. It reserves a box that scales with your page width. Without it, an iframe falls back to a small fixed size or collapses to nothing in some themes. allow. Lets the game use fullscreen, sound, gamepads and pointer lock. If you trim this list, keyboard-and-mouse shooters or controller games can stop working.loading="lazy". The game only loads when the visitor scrolls near it.title. Screen readers announce it. Use the game's real name.- The
srcaddress. Keep it exactly as copied. The embed points to the hosted player, so updates and fixes to the game reach your site without you doing anything.
Portrait games need a different box
Many mobile-style games are built for a tall screen. Forced into a 16:9 box, they become a thin strip in the middle. Check the game's orientation in the catalog, and for portrait games use a tall box with a maximum width:
<div style="position:relative;width:100%;max-width:420px;margin:0 auto;aspect-ratio:9/16;overflow:hidden;background:#000;">
<iframe src="https://playkovo.com/embed/GAME-SLUG" title="Game on PlayKovo"
style="position:absolute;inset:0;width:100%;height:100%;border:0;"
loading="lazy" allow="fullscreen; autoplay; gamepad; pointer-lock" allowfullscreen></iframe>
</div>
The 420px cap stops the game from becoming enormous on desktop. On a phone it simply fills the width.
Match the game to your visitors
Each game lists whether it is built for desktop, mobile or both. If most of your readers are on phones, a game that needs a keyboard will frustrate them. Check your analytics for device split before choosing. A site with 70% mobile traffic should lean on games marked for mobile or all devices.
Common reasons an embed shows up blank
- A Content-Security-Policy header. If your site sets one, add
frame-src https://playkovo.com. Otherwise the browser blocks the frame, and the page shows an empty box with an error in the console. - The editor strips the iframe. Some CMS visual editors remove iframe tags or rewrite attributes. Paste the code in the HTML or "custom code" view, not the visual view, and re-open the page after saving to check it survived.
- A referrer restriction. Do not add
referrerpolicy="no-referrer"to the iframe. PlayKovo identifies the embedding website from the referrer, and without it your launches cannot be counted. - A parent element with
overflow:hiddenand no height. Check that the wrapper div actually has a visible height in the browser inspector.
Give the game room on the page
- Do not put a game in a narrow sidebar column. Fullwidth or a wide content column works far better.
- Keep ads and pop-ups away from the frame. Overlays that cover the game area cause accidental taps. See how play counts differ between portals for why accidental launches skew your numbers.
- Write a few sentences about the game above or below it: what it is, controls, who it suits. A page with only an iframe gives search engines and visitors very little to work with.
Final check before publishing
- Open the page on a real phone, not just a narrowed desktop window.
- Tap the fullscreen button and exit again.
- Rotate the phone if the game supports both orientations.
- Confirm sound plays after the first tap (browsers block autoplay audio until the visitor interacts).
If you want launches from your domain to show up in a dashboard, you can register your website. It is optional; embedding works without an account.


