0% found this document useful (0 votes)
3 views

Html add two numbers

This document is an HTML page that provides a simple user interface for adding two numbers. It includes input fields for the numbers, a button to perform the addition, and displays the result. The page is styled with CSS for a clean and user-friendly layout.

Uploaded by

7fr99vxk7f
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Html add two numbers

This document is an HTML page that provides a simple user interface for adding two numbers. It includes input fields for the numbers, a button to perform the addition, and displays the result. The page is styled with CSS for a clean and user-friendly layout.

Uploaded by

7fr99vxk7f
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

<!

DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Two Numbers</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
.container {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
input {
margin: 5px 0;
padding: 10px;
width: 100%;
box-sizing: border-box;
}
button {
padding: 10px;
width: 100%;
background-color: #007BFF;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
.result {
margin-top: 10px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<h2>Add Two Numbers</h2>
<input type="number" id="num1" placeholder="Enter first number">
<input type="number" id="num2" placeholder="Enter second number">
<button onclick="addNumbers()">Add</button>
<div class="result" id="result"></div>
</div>

<script>
function addNumbers() {
const num1 = parseFloat(document.getElementById('num1').value);
const num2 = parseFloat(document.getElementById('num2').value);
const result = num1 + num2;
document.getElementById('result').textContent = 'Result: ' + result;
}
</script>
</body>
</html>

You might also like