This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.



Sets and retrieves the format and style of an object.


No properties.


No methods.


No events.


This example sets a value on the runtimeStyle object to affect the currentStyle object, but not the style object.

function fnChangeValue(sValue){
   if(oDIV.runtimeStyle.backgroundColor =={
   oDIV.runtimeStyle.backgroundColor = sValue;
   console.log( +
      "\n" + oDIV.currentStyle.backgroundColor +
      "\n" + oDIV.runtimeStyle.backgroundColor);
<DIV ID = "oDIV">
This is a demonstration DIV.
<INPUT TYPE = "button" VALUE = "Change Color" onclick="fnChangeValue('blue')">

View live example



The runtimeStyle object sets and retrieves the format and style of an object, and overrides existing formats and styles in the process. Other than having precedence over the style object and not persisting, the runtimeStyle object is equivalent to the style object. To change or clear multiple style properties simultaneously, use this object with the cssText property. For example, to change the font color and background color of a DIV element, you could use the following code:

<DIV onclick="this.runtimeStyle.cssText = 'color:red;background-color:blue;border:5px solid black;'">
Click this DIV to change style properties.</DIV>

Windows Internet Explorer 8 or later. The behavior of setAttribute method depends on the current document compatibility mode. For more information, see Attribute Differences in Internet Explorer 8.

See also

Related pages