Creating a HTML 5 page using "output" tag

The HTML <output> tag is used for displaying or showing the result of a calculation or operation , such as one performed by a script.

The <output> tag was first introduced in HTML 5.

This walk through will guide you on how to create a HTML 5 page which can multiply two numbers. It can also be useful for creating the first HTML 5 page for many beginners.

  • First of all open a new text document.
  • Paste the following code in it.

            <!doctype html >
            <html ><head>
            <title>Document title.</title>


            </head>
            <body onload="multi()">
            <h1>output tag Example.</h1>
            <p><b>Implementation of &lt;output &gt; in HTML5.</b></p>
            <form action="roseindia.html" method="get" name="form">
            <label>Multiplication of two number:</label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<output name="result">
            </output> </form></body>
            </html>

  • Now paste the following javascript code between the </title> and </head> tags.

    <script type="text/javascript">
         function multi()
         {
             a=parseInt(prompt("Enter first number.",0));
             b=parseInt(prompt("Enter first number.",0));
             document.forms["form"]["result"].value=a*b;
         }
      </script>

  • Now save the page as "First program.html".

Now you are ready to test your page by opening it (double clicking it) .

Ebook Download
View all
Learn
View all