Q:

set limit for the number of columns per row in a html table

May I know what are the ways to limit the number of columns of a Html table (e.g. 3 columns per row)?
FYI, I'm using row.insertCell() to add cells to a particular row with matching the row id. I wish to limit the cell number to only 3 per row in the table.

A:

There is no such limit in the javascript or html standard. you have to enforce it yourself as a rule during the insertion. 
A simple counter does the trick.
var items = ['c00', 'c01', 'c02', 'c10', 'c11', 'c12'];  //sample data

var table = document.getElementById("myTable");
var row;

for(var i = 0; i < items.length; i++){
  if(i % 3 == 0) {   //after every third cell add a new row and change the row variable to point to it
     row = table.insertRow(-1);      
  }
  var cell = row.insertCell(-1);  //simply insert the row
  cell.innerHTML = items[i];
}

there are a number of ways of doing it. it will really depend on how you structure your code.

