試一試
<p>“You're late!”</p>
<del>
<p>“I apologize for the delay.”</p>
</del>
<ins cite="../how-to-be-a-wizard.html" datetime="2018-05">
<p>“A wizard is never late …”</p>
</ins>
del,
ins {
display: block;
text-decoration: none;
position: relative;
}
del {
background-color: #ffbbbb;
}
ins {
background-color: #d4fcbc;
}
del::before,
ins::before {
position: absolute;
left: 0.5rem;
font-family: monospace;
}
del::before {
content: "−";
}
ins::before {
content: "+";
}
p {
margin: 0 1.8rem;
font-family: "Georgia", serif;
font-size: 1rem;
}
屬性
此元素包含全域性屬性。
cite-
此屬性定義了一個解釋更改的資源的 URI,例如指向會議記錄或故障排除系統中的工單的連結。
datetime-
此屬性指示更改的時間和日期,並且必須是一個有效的日期,可以選擇性地附加一個時間字串。如果該值無法解析為帶有可選時間字串的日期,則該元素沒有關聯的時間戳。有關不帶時間的字串的格式,請參閱有效日期字串的格式。如果包含日期和時間的字串的格式,請參閱有效本地日期和時間的格式。
無障礙
在大多數螢幕閱讀器技術的預設配置下,<ins> 元素的存在不會被播報。可以透過使用 CSS 的 content 屬性,並結合 ::before 和 ::after 偽元素來使其被播報。
css
ins::before,
ins::after {
clip-path: inset(100%);
clip: rect(1px, 1px, 1px, 1px);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
ins::before {
content: " [insertion start] ";
}
ins::after {
content: " [insertion end] ";
}
一些使用螢幕閱讀器的使用者會故意停用那些會產生過多冗餘資訊的播報。因此,很重要的一點是不要濫用此技術,僅在不瞭解內容已被插入會嚴重影響理解的情況下才使用它。
示例
html
<ins>This text has been inserted</ins>
結果
技術摘要
規範
| 規範 |
|---|
| HTML # the-ins-element |
瀏覽器相容性
載入中…
另見
- 用於標記文件中刪除內容的
<del>元素