Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM Style transition Property

  • Difficulty Level : Medium
  • Last Updated : 02 Aug, 2019

The HTML DOM Style Property is used to change the appearance of any DIV element. It’s changing the appearance whenever the mouse has hovered over that element.


  • For return the transition property:
  • For set the transition property: = "property duration timing-function 

Property Values:

transitionPropertyName of CSS property for transition effect.
transitionDurationHow much time is taken to complete the transition
transitionTimingFunctionSpeed of transition
transitionDelayStarting point of transition
initialSet to default value
inheritInherit from its parent element

Example: In this example, we are creating a div tag whose CSS is defined in style tag and when you hover the mouse on div tag after clicking on submit button the CSS will change from myDIV CSS to myDIV: hover CSS.

<!DOCTYPE html>
    <!--this style tag defines two CSS
    the first one is the CSS define for
    the button whose id is myDiv. first
    css will show when the page is load.
    second css is used when someone 
    hover the mouse on the Div -->
        #myDIV {
            border: 1px solid black;
            background-color: #0f9d58;
            width: 220px;
            height: 100;
        #myDIV:hover {
            background-color: #228B22;
            width: 500px;
    <div id="myDIV">
    <button onclick="myFunction()">submit</button>
        // this function will find a button whose id
        // is myDIV and assign its new css according 
        // to the css define in css section
        function myFunction() {
            "myDIV").style.WebkitTransition = "width 3s";
            // here all means that the transition
            // is used for all property.
            // 2s means that hover effect will complete
            // in 2s its the transaction duration time.
            "myDIV").style.transition = "width 3s";


  • Before Hover:
  • While hovering the mouse after click on submit

Note transitionDuration can be only non negative number and it can’t be zero otherwise the transaction effect will not shown.

    Instead of all we can use following css properties:

  • none: no properties get the transaction effect
  • all: this is the default value all the properties will get the transaction effect.
  • initial: Sets this property to its default value.
  • inherit: Inherits this property from its parent element.
    Supported Browsers: The browser supporte by HTML | DOM Style transition Property are listed below:

  • Google Chrome
  • Edge
  • Firefox
  • Opera
  • Apple Safari

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :