title: How to change CSS property before element is created?
body: <p>I have to modify the div's css before the <code>window.onload</code>, and <code>body.onload</code>.</p>
  
  <p></p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;style type="text/css"&gt;
              html, body {
                  width: 100%;
                  height: 100%;
                  padding: 0px;
                  margin: 0px;
              }
              div {
                  margin-left: auto;
                  margin-right: auto;
              }
          &lt;script&gt;
              HTMLDivElement.prototype.style.marginTop = (window.innerHeight/2 - HTMLDivElement.scaleHeight/2) + "px";
          &lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;div&gt;
          foo&lt;br/&gt;bar
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>