---
title:
slug: Web/HTML/Element/s
translation_of: Web/HTML/Element/s
---
HTML <s>
元素 使用删除线来渲染文本。使用 <s>
元素来表示不再相关,或者不再准确的事情。但是当表示文档编辑时,不提倡使用 <s>
;为此,提倡使用 {{ HTMLElement("del") }} 和 {{ HTMLElement("ins") }} 元素。
内容分类 | 短语内容 or 流式内容 |
---|---|
允许的内容 | 短语内容 |
标签省略 | {{no_tag_omission}} |
允许的父元素 | 任何接受短语内容的元素 |
允许的 ARIA 角色 | 任意 |
DOM 接口 | {{domxref("HTMLElement")}} |
这个元素仅仅包含 全局属性
HTMLSpanElement
接口。<s>Today's Special: Salmon</s> SOLD OUT<br> <span style="text-decoration:line-through;">Today's Special: Salmon</span> SOLD OUT
Today's Special: Salmon SOLD OUT
Today's Special: Salmon SOLD OUT
The presence of the s
element is not announced by most screen reading technology in its default configuration. It can be made to be announced by using the CSS {{cssxref("content")}} property, along with the {{cssxref("::before")}} and {{cssxref("::after")}} pseudo-elements.
s::before,
s::after {
clip-path: inset(100%);
clip: rect(1px, 1px, 1px, 1px);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
s::before {
content: " [start of stricken text] ";
}
s::after {
content: " [end of stricken text] ";
}
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 struck out would adversely affect understanding.
规范 | 状态 | 注释 |
---|---|---|
{{SpecName('HTML WHATWG','semantics.html#the-s-element','s element')}} | {{Spec2('HTML WHATWG')}} | |
{{SpecName('HTML5 W3C','textlevel-semantics.html#the-s-element','s element')}} | {{Spec2('HTML5 W3C')}} |
{{Compat("html.elements.s")}}