# Definition Tooltip

> Explains a term inside a sentence: a dotted-underlined word that reveals a short definition on hover or focus.

- Category: [CSS Effects](https://copy-css.com/category/effects)
- Tags: definition, glossary, dfn, inline tooltip, dotted underline, jargon
- Live preview: https://copy-css.com/snippets/definition-tooltip
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<p class="define-text">
  The layout uses
  <span class="define" tabindex="0" aria-describedby="define-subgrid">subgrid</span><span class="define-tip" role="tooltip" id="define-subgrid">A grid item that lines up its children with the parent grid's tracks.</span>
  so the card titles align.
</p>
```

## CSS

```css
.define-text {
  position: relative;
  max-width: 260px;
  margin: 0;
  color: #451a03;
  font: 17px/1.6 Georgia, "Times New Roman", serif;
}

.define {
  text-decoration: underline dotted #b45309 2px;
  text-underline-offset: 4px;
  cursor: help;
}

.define:focus-visible {
  outline: 2px solid #b45309;
  outline-offset: 2px;
  border-radius: 2px;
}

.define-tip {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 10;
  width: 100%;
  padding: 10px 12px;
  box-sizing: border-box;
  border-left: 3px solid #f59e0b;
  border-radius: 4px 10px 10px 4px;
  background: #fff;
  box-shadow: 0 10px 24px -10px rgba(120, 53, 15, 0.35);
  color: #78350f;
  font: 14px/1.45 system-ui, sans-serif;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s;
}

.define:hover + .define-tip,
.define:focus + .define-tip {
  opacity: 1;
  visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
  .define-tip {
    transition: none;
  }
}
```

## Notes

- This CSS Definition Tooltip is 50 lines of pure CSS (1.0 KB) with no JavaScript and no dependencies. It uses transitions, box shadows, keyboard focus styles and reduced-motion support.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
