See following javascript function.
function create_div_dynamic(){
dv = document.createElement('div');
dv.setAttribute('id',"lyr1");
dv.className="top";
dv.style.position="absolute";
dv.style.pixelLeft=20;
dv.style.pixelTop=100;
dv.style.pixelWidth=10;
dv.style.pixelHeight=20;
dv.style.backgroundColor="red";
dv.innerHTML='<br> hi <br>';
document.forms[0].appendChild(dv);
}
Vote up if you consider the answer suitable