{{Deprecated_header}}
HTML <content> 元素— Web 组件 的技术套件的废弃部分 — 用于 Shadow DOM 内部作为 {{glossary("insertion point")}},并且不可用于任何正常的 HTML,现在已被 {{HTMLElement("slot")}} 元素代替,它在 DOM 中创建一个位置,Shadow DOM 会插入这里。
注:虽然在规范的草案中出现,并且在多个浏览器中实现,这个元素依然会在规范的之后版本中移除。
| 内容分类 | 透明内容 |
|---|---|
| 允许的内容 | 流式内容 |
| Tag omission | {{no_tag_omission}} |
| 允许的父元素 | 任何接受流式内容的元素 |
| DOM 接口 | {{domxref("HTMLContentElement")}} |
这个元素包含 全局属性。
select<content> 元素。这里是一个使用 <content> 元素的简单示例。它是个 HTML 文件,包含所有所需的东西。
注:为了使这个代码有效,你使用的浏览器必须支持 Web 组件,请见 Enabling Web Components in Firefox。
<html>
<head></head>
<body>
<!-- The original content accessed by <content> -->
<div>
<h4>My Content Heading</h4>
<p>My content text</p>
</div>
<script>
// Get the <div> above.
var myContent = document.querySelector('div');
// Create a shadow DOM on the <div>
var shadowroot = myContent.createShadowRoot();
// Insert into the shadow DOM a new heading and
// part of the original content: the <p> tag.
shadowroot.innerHTML =
'<h2>Inserted Heading</h2> <content select="p"></content>';
</script>
</body>
</html>
如果你在 Web 浏览器中展示,它应该是这样。

| Specification | Status | Comment |
|---|---|---|
| {{SpecName('Shadow DOM', "#the-content-element", "content")}} | {{Spec2('Shadow DOM')}} |