How can the <output> element be used in forms, and what are its benefits?
Instruction: Describe the purpose and usage of the <output> element in HTML forms.
Context: The question assesses the candidate's knowledge of HTML form elements, focusing on the <output> element as a way to dynamically display the results of a calculation or user action.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
output represents a calculation or user-action result. Its for attribute lists IDs of contributing elements; that relationship does not perform the calculation. JavaScript must update the value.
<form id="total-form"> <label for="quantity">Quantity</label> <input id="quantity" name="quantity" type="number" min="0" max="100" step="1" required value="2"> <label for="total">Total at 5 credits each</label> <output id="total" name="total" for="quantity">10</output> </form> <script> const...