Text alignment on a dynamically created HTML element via JavaScript not working
I have a
element which is dynamically created using JavaScript when the user presses a button on the site, and I want this element to be horizontally centered, however for whatever reason the text still starts all the way from the left of the screen. For context, the textContent is added once the button is pressed, as well as the visibility being changed to visible.
Here's the JavaScript code:
const guessBlurb = document.createElement("p");
guessBlurb.id="guessBlurbID";
guessBlurb.style.position="absolute";
guessBlurb.style.textAlign="center";
guessBlurb.style.top="650px";
guessBlurb.style.visibility="hidden";
document.getElementById("guessBlurbDiv").appendChild(guessBlurb);