Re: setting css property to empty string from script

On Fri, Mar 6, 2009 at 8:50 AM, Mike Wilson <> wrote:
> When you have overrided the value of an element's CSS attribute
> through script, then you can reset the attribute back to the
> value governed by style declarations by assigning the empty
> string. Example (see *):
>  <style type='text/css'>
>    span {border: 1px solid red}
>  </style>
>  <span id=myspan>lorem ipsum</span>
>  e = document.getElementById("myspan");
>  window.getComputedStyle(e,"").borderLeftWidth
>  -> "1px"

Nonstandard. Some implementations may treat window as a reference to
document.defaultView, but window is not guaranteed to be

Try it in Safari 2, for example.

> = 2;
>  window.getComputedStyle(e,"").borderLeftWidth
>  -> "2px"

Nonstandard. Use a unit. Use a string value. Dom setters that are
standardized to take domstring should take a domstring. Assigning a
number is nonstandard and does not work consistently.


Received on Friday, 6 March 2009 22:11:48 UTC