试一试
<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>
元素