mark
The mark element represents text highlighted for reference or notation purposes, with VB status variants for success, warning, and error states.
Description
The <mark> element represents text highlighted for reference due to its relevance in a particular context. VB styles it with a subtle background derived from var(--color-interactive) using relative oklch colors, plus padding-inline and border-radius for a polished highlight. Three status variants provide semantic color coding.
When to Use
- Search results: Highlight matching search terms
- Quotations: Mark parts of a quote that are particularly relevant
- Status indicators: Build, test, security status badges
- Comparisons: Highlight differences between items
- User selections: Show text the user has bookmarked or selected
When NOT to Use
Examples
<p>Search results: The <mark>progressive</mark> enhancement approach.</p>
Status Variants
| Class | Background | Use Case |
|---|---|---|
| (default) | oklch(from var(--color-interactive) l c h / 0.2) |
Search highlights, general relevance |
.success |
oklch(60% 0.18 145 / 0.2) (green) |
Passed, approved, complete |
.warning |
oklch(75% 0.18 75 / 0.2) (amber) |
Partial, experimental, caution |
.error |
oklch(55% 0.2 25 / 0.2) (red) |
Failed, vulnerabilities, errors |
<mark class="success">Passed all tests</mark>
<mark class="warning">This feature is experimental</mark>
<mark class="error">Invalid input detected</mark>
CSS Reference
mark { background: oklch(from var(--color-interactive) l c h / 0.2); padding-inline: var(--size-2xs); border-radius: var(--radius-s);} mark.success { background: oklch(60% 0.18 145 / 0.2);} mark.warning { background: oklch(75% 0.18 75 / 0.2);} mark.error { background: oklch(55% 0.2 25 / 0.2);}
The default highlight uses relative oklch color derived from the theme's interactive color, so it adapts automatically to each theme. The status variants use fixed oklch values at 20% opacity for consistent, transparent overlays.
Highlight Effect
VB's data-effect="highlight" provides an animated version of mark-style highlighting that draws in on scroll. This is a CSS animation, not the <mark> element — but they share the same visual language.
Accessibility
- Some screen readers announce marked text, though support varies
- Don't rely solely on highlight color to convey meaning — add text labels for status variants
- Ensure sufficient contrast between highlighted text and background
- Provide context for why text is highlighted (e.g., "Search results for...")
Adding Screen Reader Context
For status variants, add a visually-hidden label so screen readers announce the state:
<mark class="error"> <span class="visually-hidden">Error: </span> Invalid input detected</mark>