title: Placing div side by side in a for loop - CSS styling
body: <p>I'm creating a div inside a for loop and placing them on the document. 2 divs are to be placed side by side and the following 2 divs below them and so on. </p>
  
  <p>Can someone suggest me what would be the css styling for this case?
  Here is my code</p>
  
  <pre><code>for (var i = 0; i &lt; piechartDataArray.length; i++) {
  
          var elementID = 'piechart' + (i+1).toString();
          var element = document.createElement('div');
          element.id = elementID;
          document.body.appendChild(element);
  
        if (i%2 == 0) {
              document.getElementById(elementID).style.width=...                 
     }else{
           document.getElementById(elementID).style.width=... 
          }
  }
  </code></pre>