Inline Semantics: time, mark, abbr and code
The small elements that label words inside text: time, mark, abbr, code, kbd, del, ins and more. What each means, how browsers style it and what tools see.
Inline Semantics: time, mark, abbr and code
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- `<time datetime="2026-11-22T09:30:00Z">` gives a human-readable date a machine-readable value. In a test the element's `dateTime` property returned the attribute and the tree exposed it as `time`.
- `<abbr title="HyperText Markup Language">HTML</abbr>` ties an expansion to an abbreviation. Browsers underline it by default, and the title text is the only place the expansion lives, so spell it out on first use.
- `<code>` marks computer code, `<kbd>` keyboard input, `<samp>` program output and `<var>` a variable. In a test `code` and `kbd` defaulted to a monospace font at 13px.
- `<mark>` highlights text relevant to the reader's current task, such as a search hit. It is not a decorative highlighter. In a test it got a yellow background and role `mark`.
- `<del>` and `<ins>` mark removed and added text, and the tree reports `deletion` and `insertion`. Use `<s>` for something no longer accurate, not for edits.
Labelling words, not blocks
Earlier lessons covered elements for blocks: paragraphs, lists, figures. Inside a sentence there is also a layer of small, specific elements. They are the difference between “some words in italics” and “this is a date”, “this is a keyboard shortcut”, “this is the match you searched for”. Each says what the words are, and browsers add a default look as a side effect.
What the elements are for
| Element | Means | Tree role in my test |
|---|---|---|
time |
a date, time or duration | time |
abbr |
an abbreviation | text (the title is the expansion) |
code |
computer code | code |
kbd |
keyboard input | text |
samp |
program output | not tested |
var |
a variable | not tested |
mark |
text relevant in this context | mark |
del / ins |
removed / added text | deletion / insertion |
sub / sup |
subscript / superscript | subscript / not tested |
small |
side comments, fine print | text |
I read these out of headless Chromium 159’s accessibility tree and its computed styles. A few defaults worth knowing: code and kbd used a monospace font at 13px, mark had a rgb(255, 255, 0) background, del had a line-through and ins an underline, abbr was underlined and small drew at about 13.3px. CSS can change all of it, but the meaning is what you are choosing.
time: a date a machine can read
“Sunday” means nothing to a program. The datetime attribute adds a standard value:
<p>Posted <time datetime="2026-11-22T09:30:00Z">Sunday</time>.</p>
In a test, the element’s dateTime property returned 2026-11-22T09:30:00Z while its text stayed Sunday, and the tree exposed it as time. What reads that value is up to the page: scripts, calendar integrations and search features. MDN lists the allowed formats, including dates, times, durations and week numbers. For a plain date, 2026-11-22 is enough.
abbr: write it out first
<abbr title="HyperText Markup Language">HTML</abbr> ties an expansion to the abbreviation. The browser underlines it and may show the title as a tooltip, but a tooltip is not reachable by touch or keyboard on every device. The accessibility snapshot I used showed only the text HTML, not the title, so I can’t say how every screen reader treats it. Don’t hide the only explanation there. Spell the term out in the text at first use, then use abbr for later ones if you want it.
code, kbd, samp, var
Think of these as the technical writer’s toolkit. code for a fragment of code, kbd for what a person presses (“press Ctrl + S”), samp for output a program printed, var for a placeholder name. For several lines of code, put code inside pre, which preserves whitespace (see entities, whitespace and comments).
mark, del, ins and friends
mark is for text relevant to what the reader is doing right now: the words matching a search, or a passage you are pointing at. It’s not a general highlighter. If you want something to look bright, that’s CSS, and if you want it important, that’s strong from the text lesson. del and ins record edits and accept datetime and cite attributes. For text that is simply no longer accurate, such as a crossed-out original price, s is the closer fit. sub and sup handle chemical formulas and footnote numbers.
A good test of whether you need one: if you’d write something different in a printed style guide, such as italic for a term, a footnote mark or a code font, there’s likely an element for it. If you’re just changing colour, you aren’t labelling meaning.
What the video covers
The embed is a clip, 1:20 to 5:30, from Giorgio Toffoli’s “The HTML Tags They NEVER Taught You” (July 2024, 7.5 minutes). The chapters in the clip are abbr (1:20), code (1:58), kbd (2:23), datalist plus option (2:40), dialog (3:48), time (4:38) and ruby plus rt plus rm (4:47). The datalist and dialog segments, about a minute and a half, belong to later lessons (textarea, select and datalist and the dialog element), and the clip has no mark, del or ins. This is the weakest pick in this batch: a fast tour, not a lesson, and it is the only recent English candidate I found that covers abbr, kbd and time together. I could not read a transcript, so I describe it only from the chapters. The role table and the defaults come from my own browser test. The deeper link starts Dave Gray’s semantic tags video at its mark and time chapter.
Where this fits
This ends the semantic structure group, which began with landmarks and passed through figures and quotations. The next group, images and media, starts with img and its text alternative.
Check yourself
A post says 'Posted Sunday'. How do you let software know the actual date?
Wrap it: `<time datetime="2026-11-22">Sunday</time>`. The visible text stays as is, and the `datetime` attribute carries a standard machine-readable value. In a test the property read back the exact string. Useful for calendars, search and scripts.
When is `<mark>` the right element, and when is it wrong?
Right for text that is relevant in the current context, such as the words matching a search query in results. Wrong as a decoration to make something stand out, which is CSS, or for importance, which is `strong`.
How is `<code>` different from `<kbd>`?
`code` marks a fragment of computer code, like `const x = 1`. `kbd` marks what the user types or presses, like Ctrl+S. Both are monospace by default. In a test both were monospace at 13px. For a multi-line listing, wrap `code` in `pre`.
You change a price from $20 to $15 in a product page. Which elements describe the edit?
`<del>$20</del> <ins>$15</ins>`. They mean 'removed' and 'added'. In a test the tree showed `deletion` and `insertion`. If $20 is merely no longer true, without being a tracked edit, `<s>` is the closer fit.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.