HTML-playground / index.html
victor's picture
victor HF staff
Update index.html
efec415 verified
raw
history blame
1.93 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Playground</title>
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
</head>
<body class="m-0 p-0">
<div class="grid grid-cols-2 w-dvh h-dvh divide-x divide-amber-300">
<div class="bg-gray-200">
<textarea id="code-input" class="w-full h-full font-mono p-2 resize-none"><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
}
h1 {
color: navy;
}
</style>
</head>
<body>
<h1>Welcome to the HTML Playground</h1>
<p id="message">Click the button to change this text.</p>
<button onclick="changeText()">Change Text</button>
<script>
function changeText() {
document.getElementById('message').innerText = 'Text changed!';
}
</script>
</body>
</html></textarea>
</div>
<div>
<iframe id="output" class="w-full h-full border-none"></iframe>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const codeInput = document.getElementById('code-input');
const output = document.getElementById('output');
function updateOutput() {
output.contentDocument.open();
output.contentDocument.write(codeInput.value);
output.contentDocument.close();
}
// Initial render
updateOutput();
// Update on every input
codeInput.addEventListener('input', updateOutput);
});
</script>
</body>
</html>