<del>:已删除的文本元素

<del> HTML 元素表示已从文档中删除的文本范围。例如,这可以在渲染 "跟踪变化" 或源代码差异信息时使用。<ins> 元素可用于相反的目的:指示已添加到文档中的文本。

¥The <del> HTML element represents a range of text that has been deleted from a document. This can be used when rendering "track changes" or source code diff information, for example. The <ins> element can be used for the opposite purpose: to indicate text that has been added to the document.

Try it

该元素通常(但不一定)通过对文本应用删除线样式来呈现。

¥This element is often (but need not be) rendered by applying a strike-through style to the text.

属性

¥Attributes

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

¥This element's attributes include the global attributes.

cite

解释更改的资源的 URI(例如会议纪要)。

datetime

此属性指示更改的时间和日期,并且必须是带有可选时间的有效日期字符串。如果该值无法解析为带有可选时间字符串的日期,则该元素没有关联的时间戳。不带时间的字符串格式参见 日期字符串。如果字符串同时包含日期和时间,则其格式将在 本地日期和时间字符串 中介绍。

示例

¥Examples

html
<p><del>This text has been deleted</del>, here is the rest of the paragraph.</p>
<del><p>This paragraph has been deleted.</p></del>

结果

¥Result

无障碍问题

¥Accessibility concerns

大多数屏幕阅读技术在其默认配置中均未声明 del 元素的存在。可以使用 CSS content 属性以及 ::before::after 伪元素来声明它。

¥The presence of the del element is not announced by most screen reading technology in its default configuration. It can be made to be announced by using the CSS content property, along with the ::before and ::after pseudo-elements.

css
del::before,
del::after {
  clip-path: inset(100%);
  clip: rect(1px, 1px, 1px, 1px);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

del::before {
  content: " [deletion start] ";
}

del::after {
  content: " [deletion end] ";
}

一些使用屏幕阅读器的人故意禁止播放会造成额外冗长的内容。因此,重要的是不要滥用此技术,并且仅在不知道内容已被删除会对理解产生不利影响的情况下应用它。

¥Some people who use screen readers deliberately disable announcing content that creates extra verbosity. Because of this, it is important to not abuse this technique and only apply it in situations where not knowing content has been deleted would adversely affect understanding.

技术总结

¥Technical summary

内容类别 措辞内容, 流动内容.
允许的内容 透明的.
标签遗漏 无,开始和结束标记都是强制性的。
允许的父级 任何接受 措辞内容 的元素。
隐式 ARIA 角色 deletion
允许的 ARIA 角色 任何
DOM 接口 HTMLModElement

规范

Specification
HTML Standard
# the-del-element

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看

¥See also

  • 用于插入文本的 <ins> 元素
  • <s> 元素用于删除线,与表示删除文本分开