# Search Term Highlight

> Rounded, readable styling for the mark element in search results, with a forced-colors fallback.

- Category: [CSS Text Effects](https://copy-css.com/category/text)
- Tags: mark, search results, box-decoration-break, forced colors, accessibility
- Live preview: https://copy-css.com/snippets/search-term-highlight
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<p class="search-snippet">Free <mark class="search-mark">CSS</mark> snippets for buttons, loaders and <mark class="search-mark">CSS</mark> grid layouts.</p>
```

## CSS

```css
.search-snippet {
  max-width: 17em;
  margin: 0;
  color: #374151;
  font: 400 18px/1.6 system-ui, sans-serif;
}

.search-mark {
  padding: 0.05em 0.25em;
  border-radius: 0.3em;
  background: #fef08a;
  color: #713f12;
  font-weight: 600;
  box-shadow: inset 0 -0.12em 0 #facc15;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

@media (forced-colors: active) {
  .search-mark {
    background: Mark;
    color: MarkText;
  }
}
```

## Notes

- This CSS Search Term Highlight is 24 lines of pure CSS (0.4 KB) with no JavaScript and no dependencies. It uses box shadows.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
