title: Creating a canvas element and setting its width and height attributes using jQuery
body: <p>I was just trying to do the following in jQuery:</p>
  
  <pre><code>var newCanvas = $('&lt;canvas/&gt;',{'width':100,'height':200,'class':'radHuh'});
  $(body).append(newCanvas);
  </code></pre>
  
  <p>This is working (kind of) and generates the following markup:</p>
  
  <pre><code>&lt;canvas style="width:100px; height:200px;" class="radHuh"&gt;&lt;/canvas&gt;
  </code></pre>
  
  <p>As most of you might know <code>canvas</code> elements don't really like CSS dimensions but expect a width and height attribute, so this object creation failed for me.</p>
  
  <p>I do know I could just do:</p>
  
  <pre><code>var newCanvas = $('&lt;canvas/&gt;',{'class':'radHuh'}).attr({'width':100,'height':200});
  </code></pre>
  
  <p>instead, but I was just wondering nonetheless if there is any way of telling jQuery that <code>width</code> and <code>height</code> should be treated as attributes when creating the element via <code>$('element',{attributes})</code> and not as CSS?</p>