Spaces:
Running
Running
<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-1 md:grid-cols-2 w-screen h-screen divide-x divide-amber-300"> | |
<div class="bg-gray-100"> | |
<textarea id="code-input" class="w-full h-full font-mono p-4 resize-none focus:outline-none"><h1>Welcome to the HTML Playground</h1> | |
<p id="message">Click the button to change this text.</p> | |
<button onclick="changeText()">Change Text</button> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
background-color: #f0f0f0; | |
padding: 20px; | |
} | |
h1 { | |
color: navy; | |
} | |
</style> | |
<script> | |
function changeText() { | |
document.getElementById('message').innerText = 'Text changed!'; | |
} | |
</script></textarea> | |
</div> | |
<div class="bg-white"> | |
<iframe id="output" class="w-full h-full border-none"></iframe> | |
</div> | |
</div> | |
<script> | |
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> | |