<s>

HTML <s> 元素 使用删除线来渲染文本。使用 <s> 元素来表示不再相关,或者不再准确的事情。但是当表示文档编辑时,不提倡使用 <s> ;为此,提倡使用 <del> 和 <ins> 元素。

内容分类 短语内容 or 流式内容
允许的内容 短语内容
标签省略 不允许,开始标签和结束标签都不能省略。
允许的父元素 任何接受短语内容的元素
允许的 ARIA 角色 任意
DOM 接口 HTMLElement

属性

这个元素仅仅包含 全局属性

实现注解: 直到 Gecko1.9.2(包含),Firefox 为这个元素实现了 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

Accessibility concerns

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 content property, along with the ::before and ::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.

规范

规范 状态 注释
HTML Living Standard
s element
Living Standard
HTML5
s element
Recommendation

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
sChrome Full support YesEdge Full support YesFirefox Full support 1
Notes
Full support 1
Notes
Notes Before Firefox 4, this element implemented the HTMLSpanElement interface instead of the standard HTMLElement interface.
IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
See implementation notes.
See implementation notes.

参见

  • <strike> 元素,另一个 <s> 元素,已经废除并且不应再用于 Web 站点。
  • <del> 元素用于代替,如果数据已经删除了。
  • CSS text-decoration-line-through 属性也用于为 <s> 元素实现前者的视觉效果。