I am struggling to position a text node within a div element in the middle of the page. These elements are all part of a mainDiv, which represents the entire page. Below is the code I have been attempting:
title = document.createElement('div');
title.appendChild(document.createTextNode("The big title!"));
title.style.color = "#F5AE20";
title.style.textAlign = "center"; //I am trying to resolve this issue
mainDiv.appendChild(title);
Despite my efforts, the title remains fixed at the top-left corner of the page instead of being centered on the top. EDIT - just for clarification, I would like to achieve this using Javascript if possible.
Thank you in advance for any assistance provided.