<del>: The Deleted Text element - HTML: HyperText Markup Language 编辑
The HTML <del>
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.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
This element is often (but need not be) rendered by applying a strike-through style to the text.
Content categories | Phrasing content, flow content. |
---|---|
Permitted content | Transparent. |
Tag omission | None, both the starting and ending tag are mandatory. |
Permitted parents | Any element that accepts phrasing content. |
Implicit ARIA role | No corresponding role |
Permitted ARIA roles | Any |
DOM interface | HTMLModElement |
Attributes
This element's attributes include the global attributes.
cite
- A URI for a resource that explains the change (for example, meeting minutes).
datetime
- This attribute indicates the time and date of the change and must be a valid date string with an optional time. If the value cannot be parsed as a date with an optional time string, the element does not have an associated time stamp. For the format of the string without a time, see Date strings. The format of the string if it includes both date and time is covered in Local date and time strings.
Examples
<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
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.
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.
- Short note on making your mark (more accessible) | The Paciello Group
- Tweaking Text Level Styles | Adrian Roselli
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of '<del>' in that specification. |
Living Standard | |
HTML5 The definition of '<del>' in that specification. |
Recommendation | |
HTML 4.01 Specification The definition of '<del>' in that specification. |
Recommendation |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论