Navigation

v0.0.4
Typography

Revision

Words added and words struck, inside the sentence they change.

On this page

A revision shows words added and words struck inside the sentence they change: a suggested edit, a tracked change, a correction. It is two classes on two native elements. ins on an <ins> sets inserted words on a wash of the success hue over a fine underline; del on a <del> takes half the ink from deleted words, on a wash of the danger hue under a strike.

Revision

<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>

#Two elements

The meaning is in the elements, not in the classes. <ins> and <del> say what happened to the words to a screen reader, to a search engine and to a browser with no stylesheet, where they are underlined and struck by default. Both take a datetime for when the change was made and a cite for a document that explains it.

The classes give them the wash. Like a mark, a revision carries across line breaks: each line of a long insertion has its own rounded ends.

#Hue and its second sign

Added and removed are a status of the words, so a revision takes the two status hues. A hue never stands alone: an insertion is also underlined and a deletion is also struck, so the two are told apart without color, by a reader who cannot see it and in forced colors, where the washes are dropped and the lines remain.

On a card and on ink

<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>

#Revision or code

A revision changes words in a sentence. When whole lines of code changed, use a code block with code-line-added and code-line-removed, which mark the line and its gutter. Words that are emphasized and not changed are a mark.

#Accessibility

  • Use <ins> and <del>, never a <span> with the class: the class is refused on any other element by the checker, because the elements are what carry the meaning.
  • Screen readers differ in whether they announce insertions and deletions by default. When the change matters to understanding, say it in the sentence too, or summarize the changes before the text.
  • A replacement reads best as the deletion followed by the insertion, with a space between them.

#Classes

ClassDescription
insInserted words, on an ins element: a wash of the success hue over a fine underline
delDeleted words, on a del element: half their ink, on a wash of the danger hue under a strike

#Source

@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 lose half their 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 {  .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;    @media (forced-colors: active) {      background: none;      text-decoration-color: CanvasText;    }  }  .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;  }  .del {    background: color-mix(in oklab, var(--color-danger) 10%, transparent);    color: color-mix(in oklab, currentColor 58%, transparent);    text-decoration-line: line-through;    text-decoration-color: color-mix(in oklab, var(--color-danger) 75%, transparent);  }}