188.4 - 93.1

How to Subtract Numbers in HTML

Subtraction is one of the basic mathematical operations, and HTML can be used to perform this operation. In this article, we'll discuss how to subtract two numbers in HTML using the - operator.

Subtracting Two Numbers in HTML

To subtract two numbers in HTML, we can use the - operator. For example, if we want to subtract 93.1 from 188.4, we can write:

188.4 - 93.1

This will give us the result of:


Multiple Ways to Subtract Numbers in HTML

There are multiple ways to subtract numbers in HTML. One way is to use the - operator, as we did above. Another way is to use JavaScript within an HTML document. For example:

<!DOCTYPE html>
    <h2>Subtracting Two Numbers in HTML</h2>
    <p>The result of 188.4 - 93.1 is:</p>
    <p id="result"></p>

      var num1 = 188.4;
      var num2 = 93.1;
      var result = num1 - num2;
      document.getElementById("result").innerHTML = result;

This will give us the same result of 95.3. In this example, we used JavaScript to subtract the two numbers and then displayed the result in an HTML <p> element with the id="result".


Subtracting numbers in HTML is a simple process that can be done using the - operator or JavaScript within an HTML document. By using these techniques, we can perform basic mathematical operations and display the results on a webpage.

Subscribe to The Poor Coder | Algorithm Solutions

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]