HTML / CSS online compiler

Write HTML, CSS and JavaScript with a live preview. Runs in your browser.

Learn HTML →
index.html
<!doctype html>
<html>
<head>
  <style>
    body { font-family: system-ui, sans-serif; display: grid; place-items: center; min-height: 80vh; }
    .card { padding: 24px 32px; border-radius: 16px; background: linear-gradient(135deg, #6366f1, #ec4899); color: white; text-align: center; }
    button { margin-top: 12px; padding: 8px 18px; border: 0; border-radius: 999px; font-size: 1rem; cursor: pointer; }
  </style>
</head>
<body>
  <div class="card">
    <h1>Hello, web!</h1>
    <p>Clicked <strong id="count">0</strong> times</p>
    <button id="btn">Click me</button>
  </div>

  <script>
    let n = 0;
    document.getElementById('btn').addEventListener('click', () => {
      n++;
      document.getElementById('count').textContent = n;
      console.log('Clicked', n, 'times');
    });
  </script>
</body>
</html>
Preview
Console

console.log output appears here