CSS Tooltip Generator
Pure-CSS tooltips from a data attribute β position, color, and arrow included.
hover me
.has-tooltip {
position: relative;
}
.has-tooltip::after {
content: attr(data-tooltip);
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%) translateY(-8px);
background: #1e293b;
color: #ffffff;
padding: 6px 12px;
border-radius: 6px;
font-size: 13px;
white-space: nowrap;
opacity: 0;
pointer-events: none;
transition: opacity 150ms ease;
z-index: 10;
}
.has-tooltip:hover::after {
opacity: 1;
}
.has-tooltip::before {
content: "";
position: absolute;
border: 6px solid transparent;
bottom: 100%;
left: 50%;
transform: translateX(-50%) translateY(-2px);
border-top-color: #1e293b;
opacity: 0;
pointer-events: none;
transition: opacity 150ms ease;
}
.has-tooltip:hover::before {
opacity: 1;
}
/* Usage: <span class="has-tooltip" data-tooltip="Your text">hover me</span> */Generated locally in your browser β nothing is uploaded.
How to Use
- 1
Choose position and colors
Four placements, background/text colors, radius, arrow.
- 2
Hover the preview
The tooltip fades in exactly as configured.
- 3
Copy CSS and markup pattern
class="has-tooltip" + data-tooltip="text" everywhere you need one.
Frequently Asked Questions
- A ::after pseudo-element reads its text from content: attr(data-tooltip) and fades in on hover β so one CSS block powers every element with a data-tooltip attribute, no JavaScript.
Related Tools
CSS Gradient GeneratorBuild linear and radial CSS gradients visuallyBox Shadow GeneratorCreate CSS box shadows with a live previewBorder Radius GeneratorGenerate CSS border-radius values visuallyFlexbox GeneratorBuild CSS flexbox layouts with a visual editorCSS Grid GeneratorBuild CSS grid layouts with a visual editorText Shadow GeneratorGenerate CSS text-shadow effects with live previewCSS Animation GeneratorCreate CSS keyframe animations with a live editorClip-Path GeneratorGenerate CSS clip-path polygon shapes visually