大网数据广告活动
Web 标准与前端开发

<output>

· 52CE 我爱测

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

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

<table class="properties"> <tbody> <tr> <th scope="row"><a href="/zh-CN/docs/Web/HTML/Guides/Content_categories">Content categories</a></th> <td><a href="/zh-CN/docs/Web/HTML/Guides/Content_categories#Flow_content">流式元素</a>,<a href="/zh-CN/docs/Web/HTML/Guides/Content_categories#Phrasing_content">短语元素</a>,<a href="/zh-CN/docs/Web/HTML/Guides/Content_categories#Form_listed">listed</a>, <a href="/zh-CN/docs/Web/HTML/Guides/Content_categories#Form_labelable">labelable</a>, <a href="/zh-CN/docs/Web/HTML/Guides/Content_categories#Form_resettable">resettable</a> <a href="/zh-CN/docs/Web/HTML/Guides/Content_categories#Form-associated_content">form-associated element</a>, palpable content.</td> </tr> <tr> <th scope="row">允许元素</th> <td><a href="/zh-CN/docs/Web/HTML/Guides/Content_categories#Phrasing_content">短语元素</a></td> </tr> <tr> <th scope="row">标签省略</th> <td>不允许,开始标签和结束标签都不能省略。</td> </tr> <tr> <th scope="row">允许父元素</th> <td>接受任何 <a href="/zh-CN/docs/Web/HTML/Guides/Content_categories#Phrasing_content">短语元素</a></td> </tr> <tr> <th scope="row">允许 ARIA 角色</th> <td>Any</td> </tr> <tr> <th scope="row">DOM 接口</th> <td>HTMLOutputElement</td> </tr> </tbody> </table>

属性

这个标签具有 全局属性。

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

例子

<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>

规范

浏览器兼容性

参见

  • Other form-related elements: form, input, button, datalist, legend, label, select, optgroup, option, textarea, fieldset, progress and meter.

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。