<embed>:嵌入外部内容元素

<embed> HTML 元素在文档中的指定点嵌入外部内容。该内容由外部应用或其他交互式内容源(例如浏览器插件)提供。

¥The <embed> HTML element embeds external content at the specified point in the document. This content is provided by an external application or other source of interactive content such as a browser plug-in.

Try it

注意:本主题仅记录定义为 HTML 生活标准 一部分的元素。它不涉及该元素的早期非标准化实现。

¥Note: This topic documents only the element that is defined as part of the HTML Living Standard. It does not address earlier, non-standardized implementation of the element.

请记住,大多数现代浏览器已经弃用并删除了对浏览器插件的支持,因此如果你希望你的网站可以在普通用户的浏览器上运行,那么依赖 <embed> 通常并不明智。

¥Keep in mind that most modern browsers have deprecated and removed support for browser plug-ins, so relying upon <embed> is generally not wise if you want your site to be operable on the average user's browser.

属性

¥Attributes

该元素的属性包括 全局属性

¥This element's attributes include the global attributes.

height

资源的显示高度,以 CSS 像素 为单位。这必须是一个绝对值;不允许使用百分比。

src

正在嵌入的资源的 URL。

type

用于选择要实例化的插件的 MIME type

width

资源的显示宽度,以 CSS 像素 为单位。这必须是一个绝对值;不允许使用百分比。

使用说明

¥Usage notes

你可以使用 object-position 属性来调整嵌入对象在元素框架内的位置,并使用 object-fit 属性来控制如何调整对象的大小以适合框架。

¥You can use the object-position property to adjust the positioning of the embedded object within the element's frame, and the object-fit property to control how the object's size is adjusted to fit within the frame.

示例

¥Examples

html
<embed
  type="video/quicktime"
  src="movie.mov"
  width="640"
  height="480"
  title="Title of my video" />

无障碍问题

¥Accessibility concerns

embed 元素上使用 title 属性 来标记其内容,以便使用屏幕阅读器等辅助技术进行导航的人员可以理解其包含的内容。标题的值应该简洁地描述嵌入的内容。如果没有标题,他们可能无法确定其嵌入的内容是什么。这种上下文转换可能会令人困惑且耗时,尤其是当 embed 元素包含视频或音频等交互式内容时。

¥Use the title attribute on an embed element to label its content so that people navigating with assistive technology such as a screen reader can understand what it contains. The title's value should concisely describe the embedded content. Without a title, they may not be able to determine what its embedded content is. This context shift can be confusing and time-consuming, especially if the embed element contains interactive content like video or audio.

技术总结

¥Technical summary

内容类别 流量内容措辞内容,嵌入内容,交互内容, 可触知的内容
允许的内容 没有任何;这是 void element
标签遗漏 必须有开始标记,并且不能有结束标记。
允许的父级 任何接受嵌入内容的元素。
隐式 ARIA 角色 没有对应的角色
允许的 ARIA 角色 application, document, img, none, presentation
DOM 接口 HTMLEmbedElement

规范

Specification
HTML Standard
# the-embed-element

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看

¥See also