<del>: 刪除文字元素
試一試
此元素通常(但不必)透過對文字應用刪除線樣式來渲染。
屬性
無障礙
大多數螢幕閱讀器技術在其預設配置中不會宣佈 del 元素的存在。可以透過使用 CSS content 屬性以及 ::before 和 ::after 偽元素來使其宣佈。
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] ";
}
一些使用螢幕閱讀器的人會故意停用宣佈建立額外冗長的內容。因此,重要的是不要濫用此技術,而應僅在不知道內容已被刪除會對理解產生負面影響的情況下應用它。
示例
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>
結果
技術總結
規範
| 規範 |
|---|
| HTML 標準 # the-del-element |
瀏覽器相容性
BCD 表格僅在瀏覽器中載入