Write HTML, CSS and JavaScript in separate tabs and see the page render as you type. The Console tab shows your logs and errors, and you can share a short link or download the finished page as one .html file. No install and no sign-up.
<!-- index.html -->
<div class="card">
<h2>Asha Rao</h2>
<p>Front-end developer</p>
<button id="follow">Follow</button>
</div>
/* style.css */
body { display: flex; justify-content: center; padding: 3rem; font-family: system-ui; }
.card { padding: 1.5rem 2rem; border-radius: 12px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.12); text-align: center; }
// script.js
document.getElementById('follow').addEventListener('click', (e) => {
e.target.textContent = 'Following';
});The editor opens with three files: index.html, style.css and script.js. Click a tab to edit that file, then press Run or Ctrl+Enter (Cmd+Enter on a Mac). The page renders in the Preview panel next to your code, and anything your script logs shows up in the Console tab. On a phone the same views sit in one row of tabs above the editor: HTML, CSS, JS, Preview and Console.
You do not have to link the files to each other. The preview puts style.css in a <style> tag in the page head and runs script.js at the end of the body, after every element exists. So document.getElementById('btn') works on the first line of your script, with no DOMContentLoaded listener.
The HTML tab takes either. A fragment such as <h1>Hi</h1><p>Text</p> renders as it is. A complete document with <!DOCTYPE html>, <head> and <body> works too. The body content goes into the preview, and the <link>, <style> and <script> tags from your head are kept. Your <title> and <meta> tags are dropped, because the preview sets its own charset and viewport.
That is what lets you test a page built on a CSS framework or a web font. Paste a Bootstrap starter template or a Google Fonts <link> tag, and the preview loads it from the CDN the way a normal browser tab would.
The preview runs in a sandboxed frame. Scripts run, alert(), confirm() and prompt() open their dialogs, and forms fire their submit event. The sandbox also blocks a few things on purpose, so your code cannot touch the page around the editor:
localStorage, sessionStorage and cookies are not available and throw a security error. Wrap storage code in try/catch, or test it in a local file.target="_blank" and calls to window.open() do not open anything.img/logo.png points at nothing, because there is no folder behind the editor. Use full https:// URLs for images, fonts and scripts.To handle a form, call event.preventDefault() in its submit handler and read the fields in JavaScript. Without it the browser tries to send the form and the preview leaves your page. Press Run to bring it back.
The Console tab captures console.log, console.info, console.warn and console.error, plus any uncaught error. The most common error in an HTML editor is Cannot read properties of null (reading 'addEventListener'). It means your script asked for an element that is not in the HTML tab, usually because of a typo in the id or a missing id attribute.
Two details save time when you debug. First, the line number in an error counts lines in the combined page, not in script.js, so it is usually a little higher than the line in your tab. Search for the function name in the message instead. Second, logged objects print as JSON text: console.log({ a: 1 }) shows {"a":1}. DOM elements and functions cannot be copied out of the preview, so a log of one does not appear. Log element.outerHTML or element.id instead.
Your three files save in your browser as you type, so closing the tab does not lose them. Open the page again in the same browser and your code is back. The trash icon resets all three tabs to the starter code.
The share icon copies a short link to your clipboard. Anyone who opens it sees your HTML, CSS and JavaScript in their own editor, with the preview already rendered. The download icon saves a single .html file with your CSS in a <style> tag and your script at the end of the body. Double-click it to open it in any browser, or upload it to any static host as your first live page.
<div class="card">. Centre it with display: flex on the body, then add border-radius and a box-shadow. The Quick HTML Example below is a starting point.@media (max-width: 600px) rule. Make your browser window narrower to watch the preview change.required and type="email" to the inputs, handle the submit event, and show a message under any field that is empty.:root, add a .dark class that changes them, and toggle that class on the body from script.js.Prefer lessons in order first? The HTML tutorial and CSS tutorial cover tags and selectors step by step, and the JavaScript tutorial covers the DOM code these projects use. Before an interview, go through the HTML interview questions.
Search for either and you find the same kind of tool. HTML is never compiled: the browser reads the markup and draws the page directly, so an online HTML compiler is an editor with a live preview. What separates one tool from another is the setup around it. Some give you one box for everything. Some ask you to sign up before you can save. Some show the result in a new tab, so you keep switching back and forth. This one keeps three files, the preview and the console on one screen, with no account and nothing to install.
When your page needs server code, the PHP compiler uses the same editor. For logic that outgrows script.js, move to the JavaScript compiler or the TypeScript compiler. The compiler hub lists every language, and how to choose an online compiler compares the options.