aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/html/element/s/index.html
blob: fb91de28b7f64371f44ec406383a57e4d74bc29a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
title: <s>
slug: Web/HTML/Element/s
translation_of: Web/HTML/Element/s
---
<div>{{HTMLRef}}</div>

<p><strong>HTML <code>&lt;s&gt;</code> 元素 </strong>使用删除线来渲染文本。使用 <code>&lt;s&gt;</code> 元素来表示不再相关,或者不再准确的事情。但是当表示文档编辑时,不提倡使用 <code>&lt;s&gt;</code> ;为此,提倡使用 {{ HTMLElement("del") }} 和 {{ HTMLElement("ins") }} 元素。</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row"><a href="/en-US/docs/HTML/Content_categories">内容分类</a></th>
   <td><a href="/en-US/docs/HTML/Content_categories#Phrasing_content">短语内容</a> or <a href="/en-US/docs/HTML/Content_categories#Flow_content">流式内容</a></td>
  </tr>
  <tr>
   <th scope="row">允许的内容</th>
   <td><a href="/en-US/docs/HTML/Content_categories#Phrasing_content">短语内容</a></td>
  </tr>
  <tr>
   <th scope="row">标签省略</th>
   <td>{{no_tag_omission}}</td>
  </tr>
  <tr>
   <th scope="row">允许的父元素</th>
   <td>任何接受<a href="/en-US/docs/HTML/Content_categories#Phrasing_content">短语内容</a>的元素</td>
  </tr>
  <tr>
   <th scope="row">允许的 ARIA 角色</th>
   <td>任意</td>
  </tr>
  <tr>
   <th scope="row">DOM 接口</th>
   <td>{{domxref("HTMLElement")}}</td>
  </tr>
 </tbody>
</table>

<h2 id="属性">属性</h2>

<p>这个元素仅仅包含 <a href="/en-US/docs/HTML/Global_attributes">全局属性</a></p>

<div class="note"><strong>实现注解</strong>: 直到 Gecko1.9.2(包含),Firefox 为这个元素实现了 <code><a href="/en-US/docs/DOM/span">HTMLSpanElement</a> </code>接口。</div>

<h2 id="示例">示例</h2>

<pre class="brush:xml">&lt;s&gt;Today's Special: Salmon&lt;/s&gt; SOLD OUT&lt;br&gt;
&lt;span style="text-decoration:line-through;"&gt;Today's Special:
  Salmon&lt;/span&gt; SOLD OUT</pre>

<h3 id="结果">结果</h3>

<p><s>Today's Special: Salmon</s> SOLD OUT<br>
 <s style="text-decoration: line-through;">Today's Special: Salmon</s> SOLD OUT</p>

<h2 id="Accessibility_concerns">Accessibility concerns</h2>

<p>The presence of the <code>s</code> 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.</p>

<pre><code>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] ";
}</code></pre>

<p>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.</p>

<ul>
 <li><a href="https://developer.paciellogroup.com/blog/2017/12/short-note-on-making-your-mark-more-accessible/">Short note on making your mark (more accessible) | The Paciello Group</a></li>
 <li><a href="http://adrianroselli.com/2017/12/tweaking-text-level-styles.html">Tweaking Text Level Styles | Adrian Roselli</a></li>
</ul>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">规范</th>
   <th scope="col">状态</th>
   <th scope="col">注释</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG','semantics.html#the-s-element','s element')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td></td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C','textlevel-semantics.html#the-s-element','s element')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td></td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<p>{{Compat("html.elements.s")}}</p>

<h2 id="参见">参见</h2>

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