How to use the CSS Tooltip Generator
- 1Type your tooltip text and choose where it appears.
- 2Pick colors, size, corner radius and whether it has an arrow.
- 3Choose an animation and an optional delay.
- 4Hover the preview button, or keep Always show on while you adjust.
- 5Copy the HTML and CSS into your project.
How the tooltip works
The generated tooltip uses only CSS. The text lives in a data-tooltip attribute on the element, and CSS draws it with a ::after pseudo-element. A second pseudo-element, ::before, draws the arrow using a border triangle. There is no JavaScript and nothing extra to load.
The tooltip appears on hover and also on keyboard focus (:focus-visible), so people using a keyboard see it too.
Accessibility
Screen readers do not reliably read text from CSS pseudo-elements. Keep tooltips for helpful extras, not essential information. If the tooltip names a button that has only an icon, also give the button an aria-label with the same text.
Avoid tooltips on touch-only interfaces for anything important, because there is no hover on phones.
Tips
- Keep tooltip text short: a few words or one sentence.
- A small delay (around 200 to 400ms) prevents tooltips flashing as the mouse passes over a toolbar.
- Make sure the tooltip colors have good contrast. Dark backgrounds with white text are the most readable.
Where tooltips go wrong
A tooltip is a hint, not a place for anything the user needs. Keep the text to a short phrase, and never hide an error message, price or required instruction behind a hover.
Hover does not exist on touch screens. If a control only makes sense with its tooltip, show the text on screen as a visible label instead, and treat the tooltip as extra help for mouse and keyboard users. The tooltip should also appear on keyboard focus, not only on mouse hover.
WCAG 2.2 sets three expectations for content that appears on hover or focus: the user can dismiss it without moving the pointer (usually with Esc), can move the pointer onto it without it vanishing, and it stays until dismissed or no longer relevant. Read the WCAG 1.4.13 explanation before shipping tooltips on a real product.
Matching the style to your page
Pick the position away from the nearest screen edge, since a tooltip near the top of the viewport that opens upward gets clipped. Use Max width to force long text onto several lines, and a delay of a few hundred milliseconds so tooltips do not flash as the pointer crosses the page.
If you set your own background and text colors, check the pair with the WCAG contrast checker. To tune the look of a dark tooltip or a button next to it, try the CSS gradient generator, and paste the finished markup into the HTML viewer to test it in isolation.
Frequently asked questions
Do CSS tooltips work without JavaScript?
Yes. This tooltip is pure CSS, using a data attribute and pseudo-elements.
Are CSS tooltips accessible?
They show on keyboard focus, but screen readers may not announce them. Use aria-label for essential information.
Why is my tooltip cut off?
A parent element may have overflow: hidden, or the tooltip runs off the screen edge. Change the position or remove the overflow setting.
How do I show a tooltip on keyboard focus too?
Add the same data-tooltip attribute to an element that can receive focus, such as a button or link. If your CSS uses :hover, add a matching :focus-visible rule so keyboard users see the hint.
Can I put an image or link inside a CSS tooltip?
Not with this approach. The text comes from an attribute, so it is plain text only. For links or images use a popover built with HTML and JavaScript instead.
Last updated · By the DailyDeskTools team
Built and written with AI assistance, then tested by hand by our team. How we make our tools