http://www.codingforums.com/showthread.php?t=57721 document.getElementById('div1').className="myclass"; where myclass is defined in CSS as: .myclass {width:50px; height:200px; background: #e0e0e0;} document.getElementById('div1').style.cssText = 'width:50px; height:200px; background: #e0e0e0;';