W3C home > Mailing lists > Public > www-style@w3.org > March 2009

setting css property to empty string from script

From: Mike Wilson <mikewse@hotmail.com>
Date: Fri, 6 Mar 2009 17:50:59 +0100
Message-ID: <BAY116-DAV1389047D3AF3BDE05AE923A4A50@phx.gbl>
To: "'www-style'" <www-style@w3.org>
Message-ID: <037f01c99e7b$ba485b80$0a01a8c0@mikedeskxp>
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"

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

* e.style.borderLeftWidth = "";
* window.getComputedStyle(e,"").borderLeftWidth
* -> "1px"

Is this behaviour specified by any standard, or is it just a
convention implemented by UAs? (I don't find it but maybe I am
not looking in the right places.)

Best regards
Mike Wilson
Received on Friday, 6 March 2009 16:51:55 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:17 GMT