Skip to content
Websites & files

How to make a single-file HTML page

One file that carries its own styles, scripts and images can be pasted, emailed, attached or published without anything going missing. Here is how to build one — and when not to.

7 min readUpdated October 2026By the HTMLtoLink team
Short answer

A single-file HTML page keeps its CSS in a <style> tag, its JavaScript in a <script> tag, and small images as Base64 data: URIs, so nothing depends on other files. Merge your files with the HTML, CSS & JS combiner, embed images with image to Base64, and paste the result into HTMLtoLink.

The skeleton

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>My page</title>
  <style>
    body { font-family: system-ui, sans-serif; margin: 0; padding: 24px; }
  </style>
</head>
<body>
  <img src="data:image/svg+xml,..." alt="Logo">
  <h1>Hello</h1>
  <script>
    document.querySelector('h1').addEventListener('click', () => alert('Hi'));
  </script>
</body>
</html>

Step by step

  1. CSS: paste the contents of each stylesheet into one <style> block in the head, in the same order the <link> tags were.
  2. JavaScript: paste each script into a <script> block at the end of the body, libraries first.
  3. Images: convert logos and icons to data URIs. Keep each under ~100 KB.
  4. Fonts: use a Google Fonts <link> (it needs internet) or a system font stack — embedding font files bloats the page.
  5. Libraries: load from a CDN over https://. The page then needs a connection, which is fine for a hosted link.
HTML, CSS & JS Combiner
Merge separate HTML, CSS and JavaScript into one self-contained file
Open the free tool

One gotcha: </script> inside JavaScript

If your JavaScript contains the text </script> (for example in a string), the browser ends the script block there. Write it as <\/script>. The combiner does this for you.

When a single file is the wrong choice

  • Many or large photos — Base64 adds a third and blocks rendering. Upload a ZIP instead.
  • A multi-page site — each page would duplicate all the CSS.
  • Video or audio — keep them as files.

Rule of thumb: if the finished file is over 2–3 MB, a folder upload will feel faster to everyone who opens it.

Questions people ask

Is a single-file HTML page slower?

For small pages it is faster — one request instead of several. With large embedded images it is slower, because nothing renders until the whole file arrives.

Can I put a whole web app in one HTML file?

Yes. Many games, calculators, dashboards and AI-generated tools are single files. Load frameworks from a CDN and keep data in localStorage or a public API.

Read next

Your HTML deserves a real link

Paste code, drop a file, a ZIP or a whole folder — get a live URL with your own address, an optional password and a QR code. Free to start with Google sign-in; paid plans keep links online for good.

Turn HTML into a link