Output Tag in HTML5
In this article I am going to describe about the implementation and use of Output Tag in HTML5.
Output Tag
The output tag is used for displaying result of calculation on browser.<Output> Tag is new in HTML5.
It has both start and end tag.
Syntax
Syntax of <output> tag in HTML5
<output name="">Text<output>
Browser Support
<output> tag is supported in all major browsers except Internet Explorer
Attributes
Attribute |
Value |
Description |
name |
name |
Specifies the name for the output element |
for |
element_id |
id of one or more related fields |
form |
form_id |
Specifies one or more form the output element belongs to |
Example of Output tag in HTML5
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Output Tag</title>
<script type="text/javascript">
function sum() {
a = parseInt(prompt("Enter first number.", 0));
b = parseInt(prompt("Enter second number.", 0));
document.forms["form"]["result"].value = a + b;
}
</script>
</head>
<body onload="sum()">
<h1>output tag Example.</h1>
<p><b>Implementation of <output > in HTML5.</b></p>
<form action="output.html" method="get" name="form">
<label>Addition of two number:</label>
<output name="result">
</output>
</form>
</body>
</html>
Output
Step1-We have taken first number as 10
Step2-We have taken second number as 5
Step3-We get the final output: