HTML | DOM Style animationFillMode Property Last Updated : 12 Jul, 2022 Comments Improve Suggest changes Like Article Like Report The DOM style animationFillMode property is used to specify the style of an element when the animation is not playing or when an animation is finished or when there is a delay in animation. The animationFillMode property can override the default behavior of CSS animations by which CSS animations affect the element when the first keyframe is "played" and then stops affecting it once the last keyframe has completed. Syntax: For returning the animationFillMode property use the following:object.style.animationFillMode;To set the animationFillMode property use below:object.style.animationFillMode = "none|forwards|backwards|both| initial|inherit"; Return Values: It returns a string that represents the animation-fill-mode property of an element Property values: none: It will not apply any styles to the target before or after it is executing.forwards: It will apply the property values for the time the animation ended.backwards: It will apply the property values defined in the keyframe that will start the first iteration of the animation, during the period defined by animation-delay.both: It will apply the property values for forwards as well as backwards to the animation.initial: It will set the property to its default value.inherit: This property is inherited from its parent. Approach: The <div> element get the style values set by the first keyframe before the animation starts during the animation delay period. Example-1: html <!DOCTYPE html> <html> <head> <style> div { width: 50px; height: 50px; background: green; position: relative; -webkit-animation: animate 2s 1; /* Chrome, Safari, Opera */ animation: animate 2s 2; } /* Chrome, Safari, Opera */ @-webkit-keyframes animate { from { left: 500px; } to { left: 0px; } } @keyframes animate { from { left: 500px; } to { left: 0px; } } </style> </head> <body> <p>Click the "Try it" button to let the DIV element keep the styles set by the last keyframe: to {left:0px;}, when the animation is finished.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { // Code for Chrome, Safari, and Opera document.getElementById( "div1").style.WebkitAnimationFillMode = "backwards"; document.getElementById( "div1").style.animationFillMode = "backwards"; } </script> <div id="div1"></div> </body> </html> Output: Example-2: html <!DOCTYPE html> <html> <head> <style> div { width: 50px; height: 50px; background: green; position: relative; -webkit-animation: animate 2s 1; /* Chrome, Safari, Opera */ animation: animate 2s 2; } /* Chrome, Safari, Opera */ @-webkit-keyframes animate { from { left: 0px; } to { left: 500px; } } @keyframes animate { from { left: 0px; } to { left: 500px; } } </style> </head> <body> <p>Click the "Try it" button to let the DIV element keep the styles set by the last keyframe: to {left:500px;}, when the animation is finished. </p> <button onclick="myFunction()"> Try it </button> <script> function myFunction() { // Code for Chrome, Safari, and Opera document.getElementById( "div1").style.WebkitAnimationFillMode = "forwards"; document.getElementById( "div1").style.animationFillMode = "forwards"; } </script> <div id="div1"></div> </body> </html> Output: Supported Browsers: The browsers supported by animationFillMode property are listed below: Google Chrome 43.0 and aboveEdge 12.0 and aboveFirefox 16.0 and aboveOpera 30.0 and aboveSafari 9.0 and aboveInternet Explorer 10.0 and above Comment More infoAdvertise with us Next Article HTML | DOM Style fontStyle Property C chaitanyashah707 Follow Improve Article Tags : Web Technologies HTML HTML-DOM HTML-Property Similar Reads HTML | DOM Style fontStyle Property HTML DOM Style fontStyle Property is used to set or get font style of an element dynamically. Syntax: To set the fontStyle property :object.style.fontStyle = normal|italic|oblique|initial|inherit;To get fontStyle property value:object.style.height Property values: Valuenormalitalicobliqueinitialinhe 2 min read HTML DOM Style wordSpacing Property The Style wordSpacing property in HTML DOM is used to set or return the spacing between the words. It can also be used to specify space between words. Syntax: It returns the wordSpacing property. object.style.wordSpacing It is used to set the wordSpacing property. object.style.wordSpacing = "normal 2 min read HTML | DOM MouseEvent clientY Property The MouseEvent clientY property is a read-only property which is used to return the vertical coordinate of the mouse pointer based on the current window when a mouse event was triggered. Syntax : event.clientY Return Value: It returns a number that represents the vertical coordinate of the mouse poi 1 min read HTML DOM TransitionEvent elapsedTime Property The Transition Event elapsedTime property returns the duration in seconds that a CSS transition has been running when the transition event is fired. It is useful for tracking the timing of transition animations.Syntax :event.elapsedTimeReturn Value: It returns transition duration in seconds when eve 1 min read HTML DOM characterSet Property The characterSet property is used to return the character encoding for the document at the time of parsing. It is the character set that has been used for the document rendering also the user can override the encoding. The characterSet property will return null if the document is created in memory.S 2 min read HTML DOM | Style pageBreakBefore Property The Style pageBreakBefore property is used for setting or returning the page-break behavior before an element in printing or print preview. The Style pageBreakBefore property does not affect the absolutely positioned elements. Syntax : object.style.pageBreakBefore Return Values: It returns a string, 2 min read HTML DOM | Style pageBreakInside Property The Style pageBreakInside property is used for setting or returning the page-break behavior inside an element in printing or print preview. The Style pageBreakInside property does not affect the absolutely positioned elements. Syntax : To get the property:object.style.pageBreakInsideTo set the prope 2 min read HTML | DOM Style columnCount Property The DOM Style columnCount property specifies a number that defines the number of columns an element should be divided into. Syntax : To return the value: object.style.columnCount To set the value: object.style.columnCount = "number|auto|initial|inherit" Property Values: number: Specifies the number 4 min read HTML | DOM Style backgroundSize Property The HTML DOM Style backgroundSize Property is used to set or return the size of the background image. Syntax: To get the backgroundSize propertyobject.style.backgroundSizeTo set the backgroundSize propertyobject.style.backgroundSize = "auto | length | percentage | cover| contain |initial | inherit" 6 min read HTML | DOM Style font Property The HTML DOM Style's font property is used to change the element's font properties. It can be used to change the font style, weight, size, and family. Syntax: To set the font style :node.style.font = "font-properties font-size font-family;"To get the current font style:node.style.font; Return Values 2 min read Like