td, th {
padding: 10px;
border: 1px solid #ccc;
}
body {
padding: 1rem;
}
var table = document.createElement('table'),
tbody = document.createElement('tbody'),
i, rowcount;
table.appendChild(tbody);
for (i = 0; i <= 3; i++) {
tbody.insertRow(i);
for (x = 0; x <= 2; x++) {
tbody.rows[i].insertCell(x);
tbody.rows[i].cells[x].appendChild(
document.createTextNode('Row ' + i + ', Col ' + x)
);
}
}
table.createCaption();
table.caption.appendChild(
document.createTextNode('A DOM-generated Table')
);
document.body.appendChild(table);
This Pen doesn't use any external CSS resources.