var square = document.createElement('div'); var container = document.getElementById('container'); container.appendChild(square); element.classList.add('square');