CSS | animation-delay Property

The animation-delay property in CSS is used to specify the delay for the start of an animation. The animation-delay value is defined in seconds (s) or milliseconds (ms).

Syntax:

animation-delay: time|initial|inherit;

Property Values:



  • time: This value is optional. It is used to define the number of seconds (s) or milliseconds (ms) to wait before the animation will start, that is the amount of time for which the animation will be delayed. The default value is 0. Negative values are allowed. If a negative value is used, the animation will start as if it had already been playing for N seconds/milliseconds.
  • initial: This value is used to set the property to its default value.
  • inherit: This value is used to inherits the property from its parent element.

Example: HTML program to illustrate the CSS animation-delay property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
    <head
        <title>
             CSS | animation-delay Property
        </title>
        <style
            .geeks { 
                font-size: 40px; 
                text-align:center; 
                font-weight:bold; 
                color:#090; 
                padding-bottom:5px; 
                font-family:Times New Roman; 
            
              
            .geeks1 { 
                font-size:17px; 
                font-weight:bold; 
                text-align:center; 
                font-family:Times New Roman; 
            
              
            #one { 
                animation-name: example; 
                animation-duration: 10s; 
                  
            
              
            #two { 
                animation-name: example; 
                animation-duration: 10s; 
                animation-delay: 10s; 
            
              
            @keyframes example { 
                from { 
                    background-color: orange; 
                
                to { 
                    background-color: white; 
                
            
        </style
    </head
    <body
        <div class = "geeks">
            GeeksforGeeks
        </div
          
        <div class = "geeks1">
            A computer science portal for geeks
        </div
          
        <!-- Animation of below h2 tag is not delayed
            and begins as soon as the page is loaded 
            in the browser -->
        <h2 id="one">
            Text animation without delayed.
        </h2
          
        <!-- The animation of below h2 tag is delayed for 10s
             That is, it begins after 10s of successfully 
             loading of the current page -->
        <h2 id="two">
            Text animation with 10 second delay.
        </h2
    </body
</html>                                    

chevron_right


Output:
animation delay

Supported Browser: The browser supported by animation-delay are listed below:

  • Google Chrome 43.0
  • Internet Explorer 10.0
  • Firefox 16.0
  • Opera 30.0
  • Safari 9.0


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 :
Practice Tags :


Be the First to upvote.


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