A designer asks whether a button animation is possible. A support ticket needs a minimal example that reproduces a layout bug. You want to test an idea for a pricing toggle before touching the real codebase. In all of these cases, spinning up a project folder, a build tool and a dev server is overkill. What you need is a scratchpad where HTML, CSS and JavaScript run together and you see the result instantly.
This guide explains how the three languages divide the work, how to structure a small prototype so it stays readable, and how to build and export one in a browser-based editor. It also covers when a playground is the wrong tool and a local project is worth the setup.
How HTML, CSS and JavaScript fit together
Every web page is a combination of three layers:
- HTML describes structure and meaning: headings, paragraphs, buttons, form fields.
- CSS controls presentation: layout, colour, spacing, typography, transitions.
- JavaScript adds behaviour: responding to clicks, changing content, fetching data.
A browser reads the HTML first, applies the CSS, and then runs scripts that can modify both. The order matters. A script that looks up an element before that element exists in the document returns null. That is why scripts are usually placed at the end of <body> or marked with defer.
A minimal complete page that uses all three looks like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Toggle demo</title>
<style>
.panel { display: none; padding: 12px; border: 1px solid #ccc; }
.panel.open { display: block; }
</style>
</head>
<body>
<button id="toggle">Show details</button>
<div class="panel" id="panel">Delivery takes 3 to 5 working days.</div>
<script>
const btn = document.getElementById("toggle");
const panel = document.getElementById("panel");
btn.addEventListener("click", () => {
const open = panel.classList.toggle("open");
btn.textContent = open ? "Hide details" : "Show details";
});
</script>
</body>
</html>
Notice the pattern: JavaScript does not set colours or sizes directly. It toggles a class, and CSS decides what that class looks like. Keeping each concern in its own layer is the single most useful habit for prototypes that later become real code.
Build a prototype in the HTML CSS JS Editor
Our HTML CSS JS Editor gives you one tab per language and assembles them into a page for you, so you only write the parts that matter.
- Open the HTML CSS JS Editor. A small click-counter example is loaded; press Clear to start from nothing or keep it as a reference.
- In the HTML tab, write only the contents of
<body>. The editor adds the doctype,<head>, charset and viewport tags automatically. - Switch to the CSS tab and add your styles. They are placed in a
<style>block in the head. - Switch to the JavaScript tab and add behaviour. The script is inserted at the end of the body, so your elements already exist when it runs.
- Watch the Live preview update shortly after you stop typing. Use Re-run to reset state, for example to replay an animation or clear counters.
- Open the Console below the preview to see
console.logoutput and any errors with line numbers. - Test responsiveness with Tablet (768px) and Phone (375px), then use Download to save everything as a single
index.htmlfile, or Open in new tab to view it full screen.
The Tab key inserts two spaces instead of leaving the editor, which keeps indentation consistent while you type.
A simple workflow for prototypes
Prototypes get messy quickly. A few rules keep them useful:
- Start with plain HTML. Get the content and structure right before styling. If the unstyled page makes sense, it will also make sense to screen readers.
- Add layout, then decoration. Sort out flexbox or grid first, then colours and shadows. Tools like the Flexbox Playground help you find the right layout properties without trial and error.
- Use classes as the contract. Let JavaScript add and remove classes; let CSS define what they mean.
- Log state changes. A
console.login each event handler makes it obvious when something fires twice or not at all. - Keep sample data realistic. Long names, empty states and three-digit prices reveal layout problems that "Lorem ipsum" hides.
Other ways to prototype
Online playgrounds with accounts
Services such as CodePen, JSFiddle and CodeSandbox offer similar editors plus saving, forking and sharing by URL. They are the better choice when you want a permanent public link, collaboration or npm packages. The trade-off is that your code is stored on their servers and usually needs an account.
A local HTML file
A single .html file in a text editor, opened in your browser, is still a perfectly good prototype. It works offline and lives in your own version control. You lose the instant preview and built-in console, although browser developer tools (F12) cover the console part.
A framework starter
If the prototype needs routing, components or real API calls, a framework project (React, Vue, Svelte and similar) is more realistic. It is also slower to start and easier to over-engineer. Many teams validate the interaction in a playground first and only then rebuild it properly.
Pitfalls and troubleshooting
"Cannot read properties of null"
Your script ran before the element existed or the ID is misspelled. In our editor, scripts already run after the HTML, so check spelling and case: getElementById("Panel") will not find id="panel".
Styles do not apply
Look for a missing closing brace in the CSS tab; one unclosed rule can swallow everything after it. Paste the CSS into the CSS Formatter to see where the nesting goes wrong.
Things that do not work in a sandbox
The preview runs in a sandboxed frame with its own origin. Code that reads cookies or storage from another site, opens real payment flows or depends on being the top-level window may behave differently than on a normal site. For those cases, download the file and test it on a local server.
Moving the prototype into a real project
The downloaded index.html contains your CSS in a <style> block and your script in a <script> block. When you move it into a project, split those into styles.css and app.js, and run them through the JavaScript Formatter so they match your team's style.
Frequently asked questions
Do I need to write the head and body tags?
No. Write only the body content in the HTML tab. The editor wraps it in a complete document with a doctype, charset and viewport meta tag.
Can I use external libraries?
You can add a <script src="https://…"> or <link rel="stylesheet" href="https://…"> tag to the HTML tab. The library loads from its own server when the preview renders.
Is my code saved?
The editor does not store your code on a server. Use Download to keep a copy as a single HTML file before closing the tab.
Why does my animation not replay?
The preview only rebuilds when the code changes. Click Re-run to reload the frame and start the animation again.
When should I switch to a real project?
Move to a local project once you need several pages, a build step, package imports or version history. A playground is best for small, self-contained experiments.