Input & Output (<kbd>, <samp>, <output>)
When To Use
- The <kbd> element denotes user input like keyboard buttons ("Ctrl + C") or voice commands. 1
- The <samp> element in HTML is used to contain text that represents sample or quoted output from a computer program. 2
- The <output> element is used to represent an output of a calculation by the website. 4
Rules
- These <dbd> and <samp> elements does not seem to have any impact on assistive technologies. Therefore you may use them if you see fit, but they will not impact the accessibility of your website.
- The <output> element is meant for dynamic calculations in contrast to the <samp> element which only represents static output. 4
- The <output> element is often times implemented by user agents as a
aria-live
region. This means that changes inside the element are automatically announced by screen readers. 3
Sources
- MDN: <kbd>: The Keyboard Input element by Mozilla contributors is licensed under CC-BY-SA 2.5
- MDN: <samp>: The Sample Output element by Mozilla contributors is licensed under CC-BY-SA 2.5
- MDN: <output>: The Output element by Mozilla contributors is licensed under CC-BY-SA 2.5
- HTML Spec: 4.10.12 The output element is licensed under Creative Commons Attribution 4.0 International License