This online HTML, CSS and JavaScript editor lets you write web code and see the result at once. Type HTML, CSS and JavaScript in separate panes, watch the live preview, and read console.log output underneath. It is a quick playground for practice, homework and interview prep.
How to use the web code editor
- Start with the template. It has a heading, a paragraph and a button that counts clicks.
- Edit the HTML, CSS or JavaScript pane. On a phone, switch panes with the tabs.
- The preview updates about half a second after you stop typing. Untick Auto-run to update only when you click Run.
- Check the Console for
console.logoutput and error messages. - Click Reset to starter to go back to the template.
Press Tab inside a pane to indent by two spaces.
How the preview is built
The editor joins your three panes into one web page:
<!DOCTYPE html>
<html>
<head>
<style>/* your CSS */</style>
</head>
<body>
<!-- your HTML -->
<script>/* your JavaScript */</script>
</body>
</html>
Your JavaScript runs after your HTML, so document.getElementById can find your elements without waiting for a load event.
Common mistake: A common mistake beginners make is writing a full page, with
<html>and<head>tags, inside the HTML pane. Put only what belongs inside<body>there. Styles go in the CSS pane and scripts go in the JavaScript pane.
Safe by design
The preview runs inside an <iframe> with the sandbox="allow-scripts" setting. That means:
- Your JavaScript can run and change the preview.
- It cannot read this site's cookies or storage, or change this page.
- It cannot open pop-ups or submit forms to other sites.
alert(),confirm()andprompt()boxes are blocked, so useconsole.logor change the page text instead.
Nothing you type is sent to a server. The page itself works fully in your browser.
Things to try
| Try this | Where | What you learn |
|---|---|---|
Change h1 { color: ... } to another colour |
CSS | Selectors and properties |
Add display: flex; gap: 1rem; to a wrapper |
CSS | Flexbox layout |
Add console.log(document.title) |
JavaScript | Using the console |
Add an <input> and show its value on click |
HTML and JavaScript | DOM events |
| Misspell a variable on purpose | JavaScript | Reading error messages |
Learn as you practise
- New to HTML? Start with the HTML tutorial.
- Style your page with the CSS tutorial and CSS Flexbox.
- Practise array logic with JavaScript array methods.
- Preparing for interviews? Try the JavaScript DOM and events interview questions here in the editor.
Pro tip: When something does not work, add
console.loglines step by step. Seeing which line runs, and with which values, finds most bugs faster than rereading the code.
