导航

v2.1.0
排版

修订标记

在原句中标出新增和删除的文字。

本页内容

修订标记在原句中标出新增和删除的文字,可用于呈现编辑建议、修订记录或更正。它由两个原生元素及各自的类组成。在 <ins> 上使用 ins,为插入的文字铺上淡淡的成功色背景,并加一条细下划线。在 <del> 上使用 del,将删除文字的墨色略微减淡,但仍保持文字所需的对比度,铺上淡淡的危险色背景,并加上删除线。

修订

<p class="m(0) max-w(480) mx-auto leading-md">  The release is planned for <del class="del">Thursday</del> <ins class="ins">Tuesday the 17th</ins>, and it <del class="del">will probably include</del> <ins class="ins">includes</ins> the new contracts. Every stylesheet has a contract beside it<ins class="ins">, and the two change together in the same commit</ins>.</p>
<p className="m(0) max-w(480) mx-auto leading-md">  The release is planned for <del className="del">Thursday</del> <ins className="ins">Tuesday the 17th</ins>, and it <del className="del">will probably include</del> <ins className="ins">includes</ins> the new contracts. Every stylesheet has a contract beside it<ins className="ins">, and the two change together in the same commit</ins>.</p>
<p class="m(0) max-w(480) mx-auto leading-md">  The release is planned for <del class="del">Thursday</del> <ins class="ins">Tuesday the 17th</ins>, and it <del class="del">will probably include</del> <ins class="ins">includes</ins> the new contracts. Every stylesheet has a contract beside it<ins class="ins">, and the two change together in the same commit</ins>.</p>
<template>  <p class="m(0) max-w(480) mx-auto leading-md">    The release is planned for <del class="del">Thursday</del> <ins class="ins">Tuesday the 17th</ins>, and it <del class="del">will probably include</del> <ins class="ins">includes</ins> the new contracts. Every stylesheet has a contract beside it<ins class="ins">, and the two change together in the same commit</ins>.  </p></template>

#两个原生元素

修订的语义由元素承载,类只负责呈现样式。<ins> 和 <del> 向屏幕阅读器、搜索引擎以及未加载样式表的浏览器表明文字发生了什么变化。在没有样式表时,浏览器默认分别显示下划线和删除线。两个元素都可用 datetime 记录修改时间,用 cite 指向说明这次修改的文档。

类为这两个元素添加浅色背景。和高亮标记一样,修订样式可以跨行显示。较长的插入内容换行后,每行两端各自保留圆角。

#色相与线条标记

新增和删除表示文字的两种状态,因此修订使用两种状态色。插入文字同时带有下划线,删除文字同时带有删除线。无法辨别颜色的读者可以通过线条区分两者。强制颜色模式会去掉浅色背景,保留这两种线条。

卡片和墨色表面上的修订标记

<div class="card w-full max-w(360)">  <p class="m(0)">    Ships on <del class="del">Thursday</del> <ins class="ins">Tuesday</ins>, with the contracts.  </p></div><div class="sheet sheet-inverse p(20) w-full max-w(360)">  <p class="m(0)">    Ships on <del class="del">Thursday</del> <ins class="ins">Tuesday</ins>, with the contracts.  </p></div>
<>  <div className="card w-full max-w(360)">    <p className="m(0)">      Ships on <del className="del">Thursday</del> <ins className="ins">Tuesday</ins>, with the contracts.    </p>  </div>  <div className="sheet sheet-inverse p(20) w-full max-w(360)">    <p className="m(0)">      Ships on <del className="del">Thursday</del> <ins className="ins">Tuesday</ins>, with the contracts.    </p>  </div></>
<div class="card w-full max-w(360)">  <p class="m(0)">    Ships on <del class="del">Thursday</del> <ins class="ins">Tuesday</ins>, with the contracts.  </p></div><div class="sheet sheet-inverse p(20) w-full max-w(360)">  <p class="m(0)">    Ships on <del class="del">Thursday</del> <ins class="ins">Tuesday</ins>, with the contracts.  </p></div>
<template>  <div class="card w-full max-w(360)">    <p class="m(0)">      Ships on <del class="del">Thursday</del> <ins class="ins">Tuesday</ins>, with the contracts.    </p>  </div>  <div class="sheet sheet-inverse p(20) w-full max-w(360)">    <p class="m(0)">      Ships on <del class="del">Thursday</del> <ins class="ins">Tuesday</ins>, with the contracts.    </p>  </div></template>

#修订与代码改动

修订用于标出句子中的文字改动。整行代码发生改动时,请在代码块中使用 code-line-added 和 code-line-removed,在改动行及该行旁的代码边栏中做标记。仅需强调原有文字时,使用高亮标记。

#无障碍

  • 请在 <ins> 和 <del> 上使用相应的类。包括 <span> 在内的其他元素一旦使用这些类,检查器就会报错,因为修订的语义由这两个原生元素承载。
  • 屏幕阅读器是否默认读出插入和删除,取决于具体产品。如果改动关系到读者对内容的理解,请在句中也说明改动,或在正文前概述改动。
  • 替换文字时,先放删除的文字,再放插入的文字,中间留一个空格,读起来更顺畅。

#类名

类名说明
ins用于 ins 元素中的插入文本,以浅淡的成功色打底,并加上细下划线
del用于 del 元素中的删除文本,使用较淡但仍保持 4.5:1 文字对比度的墨色,配以淡危险色底纹和删除线

#源码

@master/ui/components/revision.css
/* * Revision: words added and words struck, inside the sentence they change. * On the native <ins> and <del>, which say what happened to anyone who cannot see it. Inserted words lie on * a wash of the success hue over a fine underline; deleted words take a quieter ink, on a wash of the * danger hue under a strike. The hue is a status here and never stands alone: the underline and the strike * say the same thing without it. Both carry across line breaks, like a stroke of highlighter. * For whole lines of code that changed, use a code block's added and removed lines. */@layer components.ui {  .ins, .del {    margin-inline: -.125em;    padding: .0625em .125em;    border-radius: calc(.1875rem * var(--corner-scale));    corner-shape: var(--corner-shape);    /* Longhands: the compiler orders declarations, and the shorthand would reset the thickness after it. */    text-decoration-thickness: 1px;    text-decoration-skip-ink: none;    box-decoration-break: clone;    -webkit-box-decoration-break: clone;  }  .ins {    background: color-mix(in oklab, var(--color-success) 13%, transparent);    color: inherit;    text-decoration-line: underline;    text-decoration-color: color-mix(in oklab, var(--color-success) 60%, transparent);    text-underline-offset: .22em;  }  /*   * A fifth of the ink is let go, no more: the struck words are still read, and at 80% body text keeps 4.5:1 on a   * page and on a raised sheet in both themes. Half the ink fell under 3:1.   */  .del {    background: color-mix(in oklab, var(--color-danger) 10%, transparent);    color: color-mix(in oklab, currentColor 80%, transparent);    text-decoration-line: line-through;    text-decoration-color: color-mix(in oklab, var(--color-danger) 75%, transparent);  }  /* After the washes and the lines above, so it is not overruled by them. */  @media (forced-colors: active) {    .ins, .del {      background: none;      text-decoration-color: CanvasText;    }  }}