How to center text created with doc.createTextNode()?

admin

Administrator
Staff member
Im trying to center text in a dynamically created <b> tag. Im really new at this, can someone point me in the right direction?


var label = document.createElement("b");
label.appendChild(document.createTextNode("Hello!"));
label.style.position = "absolute";
label.style.left = "100px";
label.style.bottom= "100px";
label.width = "500px";
label.style.fontSize = "8px";

label.style.textAlign = "center";

document.body.appendChild(label);


Thelabel shows up but the textAlign option doesn't seem to do anything.

Thanks
-Doug
 
Back
Top