title: Javascript offsetWidth returning undefined
body: <p>I have a JS function that gets the width of a div on my page:</p>
  
  <pre><code>function getWidth() { 
     var container = document.getElementsByClassName('tag');
     var message = "The width of the contents width padding: " + container.width + "px.\n";
     alert(message);
  }
  </code></pre>
  
  <p>The function doesn't run until page is loaded:</p>
  
  <pre><code>&lt;body onload="getWidth()"&gt;
  </code></pre>
  
  <p>And the div is defined in CSS as a percentage, with a max-width of 900px, which is what the output should be. But instead, I'm getting this alert:</p>
  
  <pre><code>The width of the contents width padding: undefinedpx.
  </code></pre>
  
  <p>I've looked around for an answer, but it looks like this should be work. Any reason why it's not working?</p>