CSS | Tooltip Fade In Animation

Tooltip is used to display information about an element when the mouse has hovered over that element. Tooltips are by default displayed with no delay (animation).

How to add animation to Tooltip?
We can add fade-in effect to the tooltip text before it becomes visible. This can be done by changing the opacity from 0 to full in a given number of seconds using the transition property in CSS.


 .tooltip .tooltip_text {
      opacity: 0;
      transition: opacity 3s;

 .tooltip:hover .tooltip_text {
      visibility: visible;
      opacity: 1;






<!DOCTYPE html>
        .tooltip {
            position: relative;
            display: inline-block;
            color: green;
            font-size: 30px;
        .tooltip .tooltip_text {
            visibility: hidden;
            font-size: 15px;
            padding: 5px;
            background-color: #cceabb;
            color: black;
            text-align: center;
            position: absolute;
            z-index: 1;
            top: 120%;
            left: 5%;
            opacity: 0;
            transition: opacity 3s;
        .tooltip .tooltip_text::after {
            content: "";
            position: absolute;
            bottom: 100%;
            left: 50%;
            margin-left: -6px;
            border-width: 8px;
            border-style: solid;
            border-color: transparent transparent #cceabb transparent;
        .tooltip:hover .tooltip_text {
            visibility: visible;
            opacity: 1;
    <div class="tooltip">GeeksforGeeks
        <span class="tooltip_text">
            A Computer science portal for geeks



Initially, the opacity of tooltip text is set to 0 and then the transition is applied to the opacity with a delay of 3s.
When we hover over “GeeksforGeeks” text, tooltip becomes 100% visible in 3s. This leads to a fade-in effect/ animation.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.