<output>

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2018.

HTML <output> 标签表示计算或用户操作的结果。

Content categories 流式元素短语元素listed, labelable, resettable form-associated element, palpable content.
允许元素 短语元素
标签省略 不允许,开始标签和结束标签都不能省略。
允许父元素 接受任何 短语元素
允许 ARIA 角色 Any
DOM 接口 HTMLOutputElement

属性

这个标签具有 全局属性

for

其他影响计算结果的标签的 ID,可以多个。

form

与当前标签有关联的 form(从属的表单)。该属性的值必须是当前文档内的表单元素的 ID。如果未指明该属性,output 标签必须是一个 form 的后代标签。该属性的用处在于可以让 output 标签脱离 form 标签,存在于一个网页文档的任意位置。

name

name 属性。

例子

html
<form oninput="result.value=parseInt(a.value)+parseInt(b.value)">
  <input type="range" name="b" value="50" /> +
  <input type="number" name="a" value="10" /> =
  <output name="result"></output>
</form>

规范

Specification
HTML
# the-output-element

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
output
for
form
name

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见