HTML Runner

How to Debug HTML Code

Find why a preview looks wrong or a script stops, using small tests and console messages.

What you’ll learn

You’ll isolate markup, styles and scripts so each test narrows the cause.

Reduce the failing input

Keep the smallest fragment that still has the problem. Verify that a simple heading renders in the same workspace.

Inspect the document

Use your browser’s Elements panel on the preview. Compare the resulting DOM with your source. Browsers can move invalid table markup or close elements implicitly.

Follow the first error

Open the runner console. Fix the first error before later ones, then use a short console.log to check the value of a selector or variable.

Try the code

<button id="save">Save</button>
<script>
  const button = document.querySelector("#save");
  console.log("Found button:", Boolean(button));
  button.addEventListener("click", () => console.info("Saved in demo"));
</script>

Open the editor and paste this sample into the HTML tab.

Troubleshooting

A blank preview can be caused by layout styles, missing content or a script loop. Try resetting the preview, then run only the markup and add one dependency at a time.

Frequently asked questions

Why do remote fonts or scripts fail here?

The preview restricts remote resource loads. Use local inline code in the runner and test integrations separately in an environment you control.

Related resources

Technical references