document.getElementById newbie question

Giganews Newsgroups
Subject: document.getElementById newbie question
Posted by:  Randall (weber.ran…
Date: Fri, 9 May 2008

I am a newbie trying to learn the DOM. Can someone tell me why the
first alert statement returns null, and the second returns the value
33px (which was set using the style="top:33px;" in the DIV tag).

Why doesn't the first alert statement pick up the style.left attribute
from the CSS?

<style type="text/css">
DIV.test {position:absolute; left:10px; top:10px; width:100; height:
<div id="Canvas" class="test" style="top:33px;">canvas</div>
<script type="text/javascript">
var el=document.getElementById("Canvas");
alert(;  //returns null... Why not 10px ???
alert(;    //returns 33px