Check out this fiddle: http://jsfiddle.net/LHsLM/1/.
I'm attempting to set the height and width of an auto-width table using inline CSS, as shown in the fiddle. However, the styles are not taking effect.
Here's the HTML:
<div id="a"></div>
CSS:
div {
height:300px;
width:500px;
overflow:auto;
}
Javascript:
var str = ["<table>"];
for (var i = 0; i < 100; i++) {
var tr = "<tr>";
for(var j = 0; j < 100; j++){
tr += "<td style='width:120px;height:40px'>" + j + "</td>";
}
tr+="</tr>";
str.push(tr);
}
str.push("</table>");
document.getElementById('a').innerHTML = str.join('');