Edits & Computer Text
Six elements handle document edits and computer-related text spans. The first two track what changed; the other four label what kind of machine text you are looking at.
What they are
<del> marks text that has been removed from a document. The browser renders it with a strikethrough by default. <ins> marks text that has been added. Both accept a cite attribute (a URL explaining the change) and a datetime attribute (an ISO 8601 timestamp), giving machines a way to understand what changed and when.
<code> wraps a fragment of code: a function name, a variable, a file path, or any string that the reader should understand as computer syntax. <kbd> marks text the user types on a keyboard, a key name like Escape or a combo like Ctrl+S. <samp> marks sample output from a program, and <var> marks a variable in a mathematical expression or code context.
Why it matters
<del> and <ins> carry meaning that a plain CSS strikethrough cannot. A stylesheet change is invisible to search engines, screen readers, and anything parsing the document structure. When a price drops from $99 to $79 and you mark the old price with <del>, the change is part of the document record. The datetime attribute goes further: it gives the exact moment of the edit in a machine-readable form.
<code> and <kbd> are the visible face of code in prose. A technical blog post that wraps command names in <code> and keyboard shortcuts in <kbd> gives copy-paste tools, screen readers, and syntax highlighters the right hook. They also signal to the reader: this is something to type or run, not just a word.
How it works
Wrap deleted content in <del> and inserted content in <ins>. Both can wrap inline text or whole block elements like paragraphs. A price correction <del>$99</del> <ins>$79</ins> is the canonical inline example; a tracked-changes document might wrap entire <p> blocks. Add cite and datetime when the context warrants it, though they are optional.
Use <code> for any string that is code: a function name in prose, a file path, a shell command embedded in a sentence. For a multi-line block, the convention is <pre><code>...</code></pre>: the <pre> preserves whitespace and the <code> provides the semantic label.
Use <kbd> for keyboard input the user gives: key names (Enter, Escape), combinations (Ctrl+S), or typed commands. Use <samp> for text the computer outputs, such as an error message or terminal response. Use <var> for a variable: the value of <var>n</var>. All four render in monospace by default and can be styled further with CSS.
Try it
See <del> and <ins> mark a price change, <code> wrap a command in prose, and <kbd> render a keyboard shortcut.
<del> and <ins>
Was: $99 Now: $79
<code> inline code
Run npm install
<kbd> keyboard input
Press Ctrl + S to save.
Editorial edits on top; computer-text elements below.
Check yourself
Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.
Remember this
<del>marks removed text (strikethrough);<ins>marks added text (underline); both supportciteanddatetime.<code>is for code fragments;<kbd>is for keyboard input the user types;<samp>is for program output.- For multi-line code blocks, use
<pre><code>...</code></pre>:<pre>preserves whitespace,<code>labels it as code. - Do not use
<code>purely for monospace styling; use a<span>with CSSfont-family: monospaceinstead.
Done with this concept?
Mark it complete to track your progress. No login needed.