let table = document.createElement("table") table.style.border='1px solid red' document.querySelectorAll("body")[0].appendChild(table) for(let i=0; i<3; i++){ let tr = document.createElement("tr") table.appendChild(tr) for(let j=0; j<4; j++){ let td = document.createElement("td") td.style.border='1px solid red' td.innerHTML='cell['+i+']['+j+']' tr.appendChild(td) } }