Professional Documents
Culture Documents
Calcuuu
Calcuuu
Calcuuu
GEEKSFORGEEKS
HTML Calculator
HTML calculator is used for performing basic mathematical operations like Addition,
subtraction, multiplication, and division.
To design the HTML calculator, we will use HTML, and CSS. HTML is used to design
the basic structure of the calculator. CSS styles are used to apply styles on the
calculator.
Approach:
Created the design with the HTML Table where first is holding the input field
with id=”result” and the rest are filled with input button.
With every click of the button, it displays the respective value of the button to
the input field by using the function dis().
myFunction() is used to set the value pressed from the keyboard to the same input
field.
Note: Please check this JavaScript Calculator for the complete calculator code
including JavaScript. In this article, we have only added HTML and CSS code to
design the calculator.
Example:
<!DOCTYPE html>
<html>
<head>
<title>HTML Calculator</title>
<style>
table {
margin-left: auto;
margin-right: auto;
}
input[type="button"] {
width: 100%;
background-color: green;
color: white;
font-size: 24px;
font-weight: bold;
border: none;
border-radius: 5px;
input[type="text"] {
font-size: 24px;
font-weight: bold;
border: none;
border-radius: 5px;
</style>
</head>
<body>
<table id="calcu">
<tr>
<td colspan="3">
</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
</table>
</body>
</html>
Output:

HTML Calculator