HTML Element: <output>
[this page | pdf | back links]
The HTML <output> element indicates the result
of a calculation (e.g. one performed by a script). It is new in HTML 5.
The attributes it can take
(other than HTML
global attributes and HTML event attributes)
include:
Attribute
|
Description
|
More
|
for
|
Specifies which form
element(s) a label calculation is bound to
|
Here
|
form
|
Name of the form that
element belongs to
|
Here
|
name
|
Name of element
|
Here
|
To create or access such an
element in JavaScript
see here. The
corresponding HTML DOM
object supports standard
DOM properties and methods, and additional properties with the same name and
meaning as the attributes of the underlying HTML element referred to above
(with the for property of the
underlying element corresponding to the htmlFor
property of the DOM object). It also supports the following additional
properties:
Property
|
Description
|
More
|
defaultValue
|
Sets / returns default value
|
Here
|
labels
|
Returns a collection of <label>
elements associated with the <output>
object
|
Here
|
type
|
Returns type of HTML element represented by the <output> object
|
Here
|
value
|
Sets / returns value of element
|
Here
|
The default style
applicable to this element is shown here.
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<output>output text</output>
<br><br>Created using JavaScript:<br>
<span id="element"></span>
<script>
var x = document.createElement("OUTPUT");
x.textContent = "output text";
// or use var txt = document.createTextNode("output text");
// x.appendChild(txt);
document.getElementById("element").appendChild(x);
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Elements