Tools/Developer Tools/HTML CSS JavaScript Live Preview

HTML Playground – Live HTML, CSS & JS Editor

Write HTML, CSS and JavaScript in separate editor tabs and see the result update live in a sandboxed preview, with full, tablet and mobile widths.

If this tool isn’t working as expected, please take a screenshot of the error and report the problem here so we can investigate and improve it.

About this tool

A browser-based HTML playground. Three editor tabs - HTML, CSS and JavaScript - feed one sandboxed preview that refreshes about 0.6 seconds after you stop typing, or straight away with Run.

The tabs use the Monaco editor (the one in VS Code) and fall back to plain text boxes if it can't load. Runtime errors, syntax errors and unhandled promise rejections are printed in red inside the preview, and console.log, warn and error output appears in a console panel under it.

The preview is an iframe whose sandbox allows scripts and modal dialogs only: your code can run and call alert(), but it can't navigate the page, open pop-ups or submit forms. Your JavaScript runs after the HTML above it, so getElementById finds your elements without waiting for DOMContentLoaded. Prettify reformats whichever tab is open, and the three icon buttons above the preview switch its width between full, 768px and 375px.

How to Use HTML CSS JavaScript Live Preview

Write HTML

Add your markup in the HTML tab.

Style With CSS

Switch to the CSS tab to style the page.

Add JavaScript

Use the JS tab for behavior. console.log output and errors appear below the preview.

Watch the Preview

The preview updates about 0.6 seconds after you stop typing, or straight away with Run.

Common Workflows

Trying a snippet before it goes into a project

Paste code from a tutorial, an answer or an AI assistant and see whether it renders and runs. The console panel shows what it logs and any error it throws.

Checking a layout at tablet and phone widths

The width buttons resize the preview to 768px or 375px, which is enough to see where a media query kicks in. They change the width only; they don't emulate touch input.

Previewing generated CSS

Paste the HTML + CSS export from the Animated Button Generator, or a snippet from the CSS Gradient Generator, to see it before it goes into your stylesheet.

Debugging a small script

Use console.log and the error output. Line numbers in error messages count from the top of the JavaScript tab, not from the whole page.

Examples

Starter: two boxes side by side (HTML + CSS)

HTML tab, then CSS tab

<div class="row">
  <div class="box">A</div>
  <div class="box">B</div>
</div>

/* CSS tab */
.row { display: flex; gap: 12px; }
.box { flex: 1; padding: 24px; background: #e0e7ff; border-radius: 8px; text-align: center; }

In the preview

Two equal-width boxes labelled A and B, side by side with a 12px gap.

Flexbox needs no JavaScript. Click the 375px width button to see the same layout at phone width.

Starter: a click counter (HTML + JavaScript)

HTML tab, then JavaScript tab

<button id="add">Clicked 0 times</button>

// JavaScript tab
const button = document.getElementById("add");
let count = 0;
button.addEventListener("click", () => {
  count += 1;
  button.textContent = "Clicked " + count + " times";
  console.log("count", count);
});

In the preview and console

Each click updates the label and adds a line such as count 3 to the console panel.

Finding an element, listening for an event and changing the page covers most small interactive snippets.

Starter: build a list with the DOM

HTML tab, then JavaScript tab

<ul id="list"></ul>

// JavaScript tab
const list = document.getElementById("list");
for (const name of ["HTML", "CSS", "JavaScript"]) {
  const item = document.createElement("li");
  item.textContent = name;
  list.append(item);
}

In the preview

A bulleted list with three items: HTML, CSS and JavaScript.

The items aren't in the HTML tab. The script creates them when the preview loads, so editing the array changes the list.

A runtime error appears in the preview

JavaScript

undefinedFunction();

Shown in the preview and console

ReferenceError: undefinedFunction is not defined

The message is printed in red inside the preview and repeated in the console panel, so a broken script is never silent. Errors thrown later, from a timer or an event handler, are caught the same way with the line counted from the top of the JavaScript tab, and a rejected promise is reported as Unhandled promise rejection followed by the reason.

Limitations

No download, share link or account

There's no button to export the combined page or generate a link. Copy the code out of each tab to keep or send it.

Three tabs, one page

There is one HTML, one CSS and one JavaScript tab: no extra files, no imports of local files and no build step.

No outside network access

Scripts, stylesheets and fonts load only from cdn.jsdelivr.net. Remote images, fetch() and XMLHttpRequest calls and files from other hosts are blocked, so code that needs an API or an outside image won't work here. Use a data: URL or inline SVG for images.

The width buttons only change the width

Choosing 768px or 375px resizes the preview. It doesn't change the user agent or emulate a phone's touch events and pixel density.

FAQs

These cover loading libraries, what the preview blocks, saving, and what this editor leaves out compared with CodePen.

Can I load Bootstrap, Tailwind or another library from a CDN?

Only from cdn.jsdelivr.net. Add a <script src="..."> or <link rel="stylesheet"> tag for a jsDelivr URL to the HTML tab - Bootstrap, Alpine.js and Chart.js are published there, for example. The preview blocks every other host, so Tailwind's Play CDN (cdn.tailwindcss.com), unpkg and cdnjs won't load, and it also blocks remote images, fetch() and XMLHttpRequest calls. The console panel reports each blocked request. For images, use a data: URL or inline SVG.

Is my code saved if I reload or close the tab?

No. Nothing is stored between visits: reloading or closing the tab clears all three tabs. Copy the code out of each tab if you want to keep it.

Is it safe to run code I didn't write?

The preview iframe is sandboxed with allow-scripts and allow-modals only. The code runs in an isolated origin, so it can't read this page, its cookies or its storage, navigate it, open pop-ups or submit forms, and it can't call an API or load remote images. It can still show alert() dialogs and use your processor, so don't run code you don't trust to behave.

How is this different from CodePen or JSFiddle?

Those add accounts, saved projects, shareable links and multi-file or package support. This online HTML editor has none of that - no login, no history, no links - so there is nothing to set up: open it and type. It suits quick tests, not projects you want to keep or share.

Get more tools like this

Leave your email so we can prioritize similar tools and updates.