Online Sales tax Calculator Tool Code fully working. just copy and paste and Enjoy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sales Tax Calculator</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background: linear-gradient(to right, #4facfe, #00f2fe);
color: #333;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.calculator-container {
background: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
padding: 20px;
width: 100%;
max-width: 400px;
text-align: center;
}
.calculator-container h1 {
font-size: 24px;
margin-bottom: 20px;
}
.input-group {
margin-bottom: 15px;
text-align: left;
}
.input-group label {
display: block;
font-weight: bold;
margin-bottom: 5px;
}
.input-group input {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
.btn {
background-color: #4caf50;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}
.btn:hover {
background-color: #45a049;
}
.result {
margin-top: 20px;
background: #f9f9f9;
padding: 15px;
border-radius: 5px;
font-size: 18px;
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}
.footer {
margin-top: 20px;
font-size: 14px;
color: #666;
}
.footer a {
color: #4facfe;
text-decoration: none;
}
.footer a:hover {
text-decoration: underline;
}
@media (max-width: 768px) {
.calculator-container {
padding: 15px;
}
}
</style>
</head>
<body>
<div class="calculator-container">
<h1>Sales Tax Calculator</h1>
<div class="input-group">
<label for="price">Item Price ($):</label>
<input type="number" id="price" placeholder="Enter item price">
</div>
<div class="input-group">
<label for="taxRate">Tax Rate (%):</label>
<input type="number" id="taxRate" placeholder="Enter tax rate">
</div>
<button class="btn" onclick="calculateTax()">Calculate</button>
<div class="result" id="result" style="display: none;">
<p id="taxAmount"></p>
<p id="totalPrice"></p>
</div>
<div class="footer">
<p>Created with <i class="fas fa-heart" style="color:red"></i> by <a href="#">Your Name</a></p>
</div>
</div>
<script>
function calculateTax() {
const price = parseFloat(document.getElementById('price').value);
const taxRate = parseFloat(document.getElementById('taxRate').value);
if (isNaN(price) || isNaN(taxRate)) {
alert('Please enter valid numbers for both fields.');
return;
}
const taxAmount = (price * taxRate) / 100;
const totalPrice = price + taxAmount;
document.getElementById('taxAmount').innerText = `Tax Amount: $${taxAmount.toFixed(2)}`;
document.getElementById('totalPrice').innerText = `Total Price: $${totalPrice.toFixed(2)}`;
document.getElementById('result').style.display = 'block';
}
</script>
</body>
</html>