Home › Developer Tools › CSS Tooltip Generator

CSS Tooltip Generator

Create a tooltip without JavaScript: pick the side, arrow, colors, size and animation, see it live, and copy clean HTML and CSS. Choose a lightweight data-tooltip attribute version or an accessible version with role="tooltip" and aria-describedby.

Last updated:

Themes
Untick to test hover and keyboard focus

Position & arrow

Animation

Bubble style

HTML

    
CSS

    
Advertisement
Advertisement

How to use the CSS Tooltip Generator

  1. Choose a theme such as Dark, Light or Brand.
  2. Pick the position (top, right, bottom or left) and the arrow size.
  3. Style the bubble: colors, padding, corner radius, font size, maximum width and distance from the element.
  4. Set the animation and an optional delay, then hover or Tab to the preview button (untick Pin to test it).
  5. Copy the HTML and CSS and change the tooltip text in your markup.

Two ways to build a CSS tooltip

Child element + role="tooltip"data-tooltip attribute
MarkupWrapper span, trigger and a tooltip spanOne attribute on the trigger
Tooltip contentAny HTML (bold text, links are not recommended)Plain text only, via content: attr(data-tooltip)
Screen readersAnnounced as the description through aria-describedbyPseudo-element text is read inconsistently
Shows on:hover and :focus-within:hover and :focus-visible
Best forImportant hints, icon buttons, formsQuick decorative hints in prototypes

How the positioning works

The trigger (or its wrapper) gets position: relative, and the bubble is absolutely positioned against it. For a top tooltip the bubble uses bottom: calc(100% + distance) and left: 50% with transform: translateX(-50%) to center it. width: max-content keeps short labels on one line while max-width wraps long ones.

The arrow is a CSS triangle: a zero-size pseudo-element with a transparent border and one colored side. A border of n pixels gives a triangle 2n wide and n tall. The generator adds the arrow size to the bubble's offset so the distance you set is measured from the element to the arrow tip.

Tooltip best practices

  • Keep tooltips short (a few words to one sentence) and never put essential information only in a tooltip, because touch screens have no hover.
  • Show the tooltip on keyboard focus as well as hover; the generated CSS does both.
  • A small show delay (100–300 ms) prevents tooltips flashing when the pointer just passes over the element.
  • Check text contrast: aim for at least 4.5:1 between the tooltip text and background.
  • Avoid interactive content such as links inside tooltips; use a popover or dialog for that.

Frequently asked questions

How do I make a tooltip with only CSS?

Position the tooltip absolutely inside a relatively positioned element and hide it with opacity: 0 and visibility: hidden. On :hover and :focus-visible (or :focus-within) set opacity: 1 and visibility: visible. The text can come from a data-tooltip attribute through content: attr(data-tooltip) on a pseudo-element, or from a child element.

How is the tooltip arrow made?

The arrow is a CSS triangle: an empty pseudo-element with a transparent border on all sides and a colored border on one side. A 6px border with border-top-color set draws a downward-pointing triangle 12px wide and 6px tall, placed right under the bubble.

Which version is more accessible?

The child-element version. The tooltip is a real element with role="tooltip" connected to the trigger with aria-describedby, so screen readers announce it reliably. Text generated with content: attr() is skipped by some screen readers, so use the data-tooltip version only for supplementary hints.

Why use visibility as well as opacity?

opacity: 0 alone leaves the tooltip in place where it can still be hovered and block clicks. visibility: hidden removes it from interaction while still allowing a smooth transition, because visibility switches at the end of the fade-out.

Can a CSS tooltip be dismissed with the Escape key?

Not with CSS alone. WCAG 1.4.13 asks that content shown on hover or focus can be dismissed without moving the pointer or focus; if your tooltip may cover important content, add a small script that hides it on Escape, or keep it short and positioned so it does not cover anything.

How do I stop the tooltip from going off-screen?

Pure CSS cannot detect the viewport edge. Choose a position with enough room (for elements near the top, use bottom), keep the max width small, or use a positioning library such as Floating UI when the trigger can be anywhere.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

CSS Toggle Switch GeneratorDesign pure-CSS toggle switches: size, colors, shape and animation. Copy accessible HTML + CSS.CSS Button GeneratorDesign CSS buttons with gradients, borders, shadows and hover and active states, then copy the code.CSS Triangle GeneratorMake CSS triangles in 8 directions with the border trick or clip-path. Set size and color, copy CSS.CSS Box Shadow GeneratorDesign layered CSS box shadows with a live preview, presets and one-click Copy CSS.Open Graph PreviewPaste OG tags and preview how links look on Facebook, X and LinkedIn.YouTube Embed Code GeneratorCreate responsive YouTube embed code with start time, autoplay, loop and privacy mode.CSS Border Radius GeneratorRound each corner, draw elliptical 8-value radii or random blob shapes and copy the CSS.CSS Flexbox GeneratorBuild flexbox layouts visually: set container and item properties, then copy the CSS and HTML.Twitter Card GeneratorCreate X / Twitter Card meta tags with Open Graph fallbacks, character counters and a live preview.CSS Grid GeneratorDraw CSS grid layouts: set tracks and gaps, drag to name areas, then copy the CSS and HTML.PX to REM ConverterConvert px to rem or em and back, with a 1-100px table and a whole-CSS converter.Glassmorphism CSS GeneratorDesign frosted-glass UI cards with blur, transparency and border sliders, then copy the CSS.CSS Text Shadow GeneratorLayer CSS text shadows with a live preview and neon, 3D, outline and retro presets.HTML Editor (Live Preview)Write HTML, CSS and JavaScript and see a live, sandboxed preview as you type.HTML to JSX ConverterConvert HTML to valid React JSX: className, htmlFor, style objects, self-closing tags and events.CSS Clip-Path GeneratorDraw CSS clip-path shapes by dragging points: polygons, circle, ellipse and inset. Copy the CSS.CSS Animation GeneratorCreate CSS keyframe animations from 23 presets with live preview, timing controls and Copy CSS.CSS Loader GeneratorPick from 14 pure CSS spinners and loaders, set color, size and speed, then copy the HTML and CSS.Cubic Bezier GeneratorDrag the control points to design a CSS easing curve, compare it with linear and copy cubic-bezier().CSS Filter GeneratorAdjust blur, brightness, contrast, hue, sepia and drop-shadow on an image and copy the CSS filter.CSS Specificity CalculatorCalculate CSS selector specificity (a, b, c), including :is(), :not(), :has() and :where(), and compare.Google Maps Embed GeneratorTurn an address or coordinates into responsive Google Maps iframe embed code, no API key.Neumorphism CSS GeneratorDesign soft UI neumorphic shapes with live preview and copy the box-shadow CSS.SVG Wave GeneratorMake layered SVG waves for section dividers and export SVG, PNG or a CSS background.SVG Blob GeneratorGenerate random organic SVG blob shapes with gradients and export SVG, PNG or CSS clip-path.CSS Clamp GeneratorTurn min/max sizes and viewport widths into a fluid CSS clamp() value in rem and vw.CSS @font-face GeneratorTurn font files or URLs into ready-to-paste @font-face rules with weights, styles and a preview.CSS Media Query GeneratorBuild @media rules for widths, orientation, dark mode and hover, or get framework breakpoints.CSS Scrollbar GeneratorStyle scrollbars: width, colors, radius and hover, with ::-webkit-scrollbar and scrollbar-color CSS.CSS Sprite GeneratorPack many icons into one sprite sheet PNG and get CSS classes with background-position.CSS Text Gradient GeneratorMake gradient text with background-clip:text: color stops, angle, font preview and fallback CSS.HTML Form BuilderDrag and drop form fields with labels and validation, then copy accessible HTML and CSS code.Iframe GeneratorCreate iframe embed code: size or responsive ratio, border, allow, sandbox, lazy load, live preview.PX to VW ConverterConvert pixels to vw and vh for any viewport size, and vw/vh back to px, with breakpoint tables.SVG Path EditorEdit an SVG path d attribute visually: drag points, edit commands, convert, scale and minify.SVG to CSS Data URITurn SVG code into a small URL-encoded data URI for CSS backgrounds, with Base64 size comparison.SVG to JSXTurn SVG code into a clean React component: camelCase attributes, style objects, TypeScript.Tailwind CSS Cheat SheetSearchable Tailwind class to CSS reference with live previews, class decoder and color palette.SVG ViewerOpen or paste SVG code to preview it live with zoom, backgrounds, size info and PNG export.Pathfinding VisualizerAnimate BFS, DFS, Dijkstra, A* and greedy search on a grid with walls, weights and mazes.Web App Manifest GeneratorCreate a PWA manifest.json and every app icon size from one image, downloaded as a ZIP.CSS Background Pattern GeneratorMake pure-CSS stripes, dots, checkerboard, zigzag and grid backgrounds and copy the code.CSS Color Filter GeneratorTurn a HEX color into a CSS filter that recolors black icons and SVGs, with an accuracy score.CSS Gradient Animation GeneratorCreate animated gradient backgrounds: pick colors, angle and speed, preview live and copy the CSS.CSS Hover Effects GeneratorPick button, link and image hover effects, tweak colors and timing, and copy the HTML and CSS.CSS InlinerMove CSS from style blocks into inline style attributes so HTML emails render in every client.CSS Shape Divider GeneratorCreate wave, tilt, curve and triangle section dividers and copy the SVG, HTML and CSS.CSS Transform GeneratorRotate, scale, skew and translate an element with sliders and copy the CSS transform code.Font Pairing ToolPreview Google Font heading and body pairs on real layouts and copy the embed code and CSS.HTML Accessibility CheckerPaste HTML to find WCAG accessibility problems with impact level, the failing element and a fix.HTML Image Map GeneratorDraw clickable rectangle, circle and polygon hotspots on an image and get image map HTML.
See all 52 Web, HTML & CSS Tools →