CSS Info Icon Tooltip

A small "i" help button beside a form label that shows a multi-line hint bubble on hover or keyboard focus.

  • info icon
  • help
  • tooltip
  • form hint
  • multiline
  • aria-describedby
HTML
<div class="info-tip-field">
  <label for="info-tip-cvc">Security code</label>
  <span class="info-tip">
    <button type="button" aria-label="What is this?" aria-describedby="info-tip-text">i</button>
    <span role="tooltip" id="info-tip-text">The 3 digits printed on the back of your card, next to the signature strip.</span>
  </span>
  <input id="info-tip-cvc" type="text" inputmode="numeric" maxlength="4" autocomplete="cc-csc">
</div>
CSS
.info-tip-field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px 8px;
  width: 220px;
  color: #111827;
  font: 600 14px system-ui, sans-serif;
}

.info-tip-field input {
  grid-column: 1 / -1;
  padding: 9px 11px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font: 15px system-ui, sans-serif;
}

.info-tip-field input:focus-visible {
  border-color: #4f46e5;
  outline: 3px solid rgba(79, 70, 229, 0.2);
  outline-offset: 0;
}

.info-tip {
  position: relative;
  justify-self: start;
}

.info-tip button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1.5px solid #9ca3af;
  border-radius: 50%;
  background: #fff;
  color: #6b7280;
  font: italic 700 11px Georgia, serif;
  cursor: help;
}

.info-tip button:hover,
.info-tip button:focus-visible {
  border-color: #4f46e5;
  color: #4f46e5;
}

.info-tip button:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

.info-tip [role="tooltip"] {
  position: absolute;
  bottom: calc(100% + 10px);
  left: -12px;
  z-index: 10;
  width: 200px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #312e81;
  color: #e0e7ff;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.info-tip [role="tooltip"]::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 16px;
  border: 6px solid transparent;
  border-top-color: #312e81;
}

.info-tip:hover [role="tooltip"],
.info-tip:focus-within [role="tooltip"] {
  opacity: 1;
  visibility: visible;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .info-tip [role="tooltip"] {
    transition: none;
  }
}

About this CSS Info Icon Tooltip

This CSS Info Icon Tooltip is 94 lines of pure CSS (1.8 KB) with no JavaScript and no dependencies. It uses transitions, transforms, CSS Grid and keyboard focus styles. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #111827
  • #d1d5db
  • #4f46e5
  • #9ca3af
  • #fff
  • #6b7280
  • #312e81
  • #e0e7ff

How to use this info icon tooltip

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .info-tip-field class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback