Here is how you can position an element at the center of a web page (both horizontally and vertically).
The content of the div with the id 'centered', will be positioned at the center of the web page. The 'absolute' positioning ensures that it is positioned at the center w.r.t the webpage or document.Instead if you want to position an element relative to an enclosing div, changing docheight and docwidth variables accordingly ensures that your element is centered.
This is often useful in situations where you want to display error messages like 404-page not found and for showing 'page redirect' messages.

Comments (1)
Leave a comment...