Preview:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Calculator</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 50px;
            text-align: center;
        }
        input {
            margin: 10px;
            padding: 10px;
            width: 80px;
        }
        button {
            padding: 10px 20px;
            margin: 5px;
        }
        #result {
            margin-top: 20px;
            font-size: 20px;
            font-weight: bold;
        }
    </style>
</head>
<body>

    <h3>Simple Calculator</h3>
    <input type="number" id="value1" placeholder="Value 1">
    <input type="number" id="value2" placeholder="Value 2"><br>
    <button name="add" onclick="add()">ADDITION</button>
    <button name="sub" onclick="sub()">SUBTRACT</button>
    <button name="mul" onclick="mul()">MULTIPLY</button>
    <button name="div" onclick="div()">DIVISION</button>

    <div id="result"></div>

    <script>
        function add() {
            const value1 = parseFloat(document.getElementById("value1").value);
            const value2 = parseFloat(document.getElementById("value2").value);
            document.getElementById("result").innerText = "Addition of " + value1 + " and " + value2 + " is " + (value1 + value2);
        }

        function sub() {
            const value1 = parseFloat(document.getElementById("value1").value);
            const value2 = parseFloat(document.getElementById("value2").value);
            document.getElementById("result").innerText = "Subtraction of " + value1 + " and " + value2 + " is " + (value1 - value2);
        }

        function mul() {
            const value1 = parseFloat(document.getElementById("value1").value);
            const value2 = parseFloat(document.getElementById("value2").value);
            document.getElementById("result").innerText = "Multiplication of " + value1 + " and " + value2 + " is " + (value1 * value2);
        }

        function div() {
            const value1 = parseFloat(document.getElementById("value1").value);
            const value2 = parseFloat(document.getElementById("value2").value);
            if (value2 === 0) {
                document.getElementById("result").innerText = "Error: Division by zero";
            } else {
                document.getElementById("result").innerText = "Division of " + value1 + " and " + value2 + " is " + (value1 / value2);
            }
        }
    </script>

</body>
</html>
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter