Skip to main content

HTML/CSS/JS Playground

Write HTML, CSS and JavaScript and see the page live in a sandboxed preview, with a console, several files and a zip download.

<main class="card">
<h1>Hello, playground</h1>
<p>Press the button to change this page.</p>
<button id="go" type="button">Change colour</button>
</main>

PreviewReady in 1 ms
Console
Page ready

Shortcuts: Ctrl+Enter run · / search (use ⌘ on Mac)

Free Online HTML, CSS and JavaScript Playground

Write a web page and see it live. Type HTML, CSS and JavaScript on the left and the page appears on the right, with a console for your messages and errors. Add as many files as you need, download them all as one zip, and nothing you write is uploaded. Use it to try a layout, test a script or share a small demo without creating a project: the page and its console update as you type.

How to use the playground

  1. Pick a file tab: index.html holds the page, style.css the styles and script.js the code that runs.
  2. Type. With Auto-run on, the page updates a moment after you stop typing; press Run (or Ctrl+Enter) to update it yourself.
  3. Read the console under the page for console.log messages and for errors, with the file and line.
  4. Press + to add a file, then link it from index.html. When you are done, open the ⋯ menu and choose Download all files (.zip).

How the files fit together

The page shown is index.html. Link other files the usual way: <link rel="stylesheet" href="theme.css"> and <script src="app.js"></script> find the files in your project. If you do not link style.css and script.js, they are attached for you, so a starter project works without any tags. SVG files in the project can be used as images.

What the preview can and cannot do

The preview is a sandbox. It runs your scripts, but it cannot read this site, your cookies or other tabs, and it cannot make network requests. To load an image, a font or a library from the web, switch on Let the preview use the internet; your code then contacts only the sites you name. If you want to try the same ideas with a framework, see the CSS Effects Generator for ready-made styles and the HTML Entity Encoder for safe special characters.

Worked example

The starter project turns a card blue each time you press its button. In index.html:

<main class="card">
  <h1>Hello, playground</h1>
  <p>Press the button to change this page.</p>
  <button id="go" type="button">Change colour</button>
</main>

In script.js, a click toggles a class and writes a line to the console:

const card = document.querySelector('.card');
document.getElementById('go').addEventListener('click', () => {
  card.classList.toggle('alt');
  console.log('Card colour changed. alt =', card.classList.contains('alt'));
});
console.log('Page ready');

Result: the page shows the card; pressing the button changes its colour and the console shows Card colour changed. alt = true.

Common mistakes

  • Linking a file by the wrong name: href="styles.css" will not find style.css. The console warns when a linked file is missing.
  • Putting script code in the HTML before the elements it uses. Code in script.js runs after the body, so it can find them.
  • Expecting a library from the web to load while the internet switch is off.
  • Using localStorage or cookies: the sandbox blocks them on purpose.

Frequently asked questions

Is the code I write uploaded anywhere?
No. Your HTML, CSS and JavaScript stay in your browser. The preview runs inside a sandboxed frame that cannot read this site or send anything out unless you switch the internet on.
Why is my preview blank?
Check the console under the preview: a JavaScript error stops the rest of your script. Also make sure index.html has some content, and that your script runs after the elements it uses exist (scripts placed in script.js run after the page body).
Can I use a library such as Bootstrap or jQuery?
Yes, in two steps. Turn on "Let the preview use the internet", then add the usual link or script tag with an https address to index.html. Without that switch the preview blocks every request, so a library from the web will not load.
How do I add more files?
Press the + button next to the file tabs, type a name that ends in .html, .css, .js or .svg, and link the file from index.html with a link or script tag. Files named style.css and script.js are attached automatically when index.html does not link them.
Why does localStorage not work in the preview?
The preview is isolated from this site on purpose, so a page you write cannot read or change anything else the browser stores. Variables and data still work for as long as the preview is open.
Can I keep my work?
Use Save to keep the project in this browser, Copy share link to put it in a link, or the menu to download all files as one zip. Saved projects never leave your device.
Is this a free alternative to CodePen?
For small experiments, yes: it gives you HTML, CSS and JavaScript with a live preview, a console and several files, with no account and no upload. It does not host or publish pages for other people.

Related tools

More Playground

View all Playground tools →