Structuring div's in HTML goes like this:
<div id="parentdiv">
<div id="childdiv"></div>
</div>
My code bellow creates 2 divs, but places the child div next to the parent div instead of inside it:
var pardiv = document.createElement('pardiv');
pardiv.setAttribute('id', "workspace");
pardiv.innerHTML = "Hello World";
pardiv.style.background = "red";
pardiv.width = 300;
pardiv.height = 300;
document.body.appendChild(pardiv);
var childdiv = document.createElement('childdiv');
childdiv.setAttribute('id', "childdiv");
childdiv.innerHTML = "Hello World";
childdiv.style.background = "yellow";
childdiv.width = 100;
childdiv.height = 100;
document.body.appendChild(childdiv);
How can a programmer structure div's like in HTML if they are created through JavaScript?