Online HTML Code runner


Online HTML Code Runner 

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Online HTML Code Runner</title>

    <style>

        body {

            font-family: Arial, sans-serif;

            background-color: #f4f4f4;

            margin: 0;

            padding: 0;

            display: flex;

            justify-content: center;

            align-items: center;

            height: 100vh;

        }


        textarea {

            width: 100%;

            height: 100px;

            box-sizing: border-box;

            padding: 10px;

        }


        button {

            background-color: #4caf50;

            color: #fff;

            padding: 10px 20px;

            border: none;

            border-radius: 4px;

            cursor: pointer;

        }


        iframe {

            width: 100%;

            height: 300px;

            border: 1px solid #ccc;

            margin-top: 20px;

        }

    </style>

</head>

<body>


    <div>

        <textarea id="code" placeholder="Enter HTML, CSS, and JavaScript code here..."></textarea>

        <button onclick="runCode()">Run Code</button>

        <iframe id="result" sandbox="allow-scripts allow-same-origin"></iframe>

    </div>


    <script>

        function runCode() {

            const code = document.getElementById('code').value;

            const iframe = document.getElementById('result');


            // Set the content of the iframe with the entered code

            iframe.contentDocument.open();

            iframe.contentDocument.write(code);

            iframe.contentDocument.close();

        }

    </script>


</body>

</html>


Followers