on-internet
← Community

Set element width or height in Standards Mode

Stack Overflow ·

Is it possible to set width or height of HTML element (ex. <div>) in JavaScript in Standards Mode? Note the following code: <html> <script language="javascript" type="text/javascript"> function changeWidth(){ var e1 = document.getElementById("e1"); e1.style.width = 400; } </script> <body> <input type="button" value="change width" onclick="changeWidth()"/> <div id="e1" style="width:20px;height:20px; background-color:#096"></div> </body> </html> When user presses the change width button, the <div>'s width should change. It works fine when doctype declaration determines Quirks Mode. In Standards

Comments

Sign in or sign up to comment and upvote.

No comments yet.