ナビゲーション

v2.1.0
タイポグラフィ

変更箇所の表示

修正対象の文の中に、追加した語句と、取り消し線を付けた削除語句を表示します。

このページの内容

変更箇所の表示は、修正案、変更の記録、訂正などで、修正対象の文の中に、追加された語句と削除された語句を示します。2 種類のネイティブ要素に、それぞれクラスを適用します。<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>

#2 つの要素

変更の意味は要素自体が伝えます。<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;    }  }}