What is Output Tag?
The <output> tag shows the result of a calculation or user action. It updates automatically.
Basic calculator:
1<form oninput="result.value = parseInt(a.value) + parseInt(b.value)">
2 <input type="number" id="a" value="10"> +
3 <input type="number" id="b" value="20"> =
4 <output name="result" for="a b">30</output>
5</form>How it works:
oninput= every time user types something, run this codeparseInt()= convert text to numberoutput= shows the result
Range slider with live output:
1<form oninput="rangeValue.value = range.value">
2 <input type="range" id="range" value="50" min="0" max="100">
3 <output name="rangeValue" for="range">50</output>
4</form>Attributes:
Attribute | What it does |
|---|---|
| Lists IDs of elements that affect this output (space separated) |
| Name of the output (for form submission) |
