A webpage aligned to center attracts the users more, than the other alignments. To align a webpage center you can use some java script which adjust’s the webpage according to the screen size or you can follow a simple way to get aligned to center. Here i am going to discuss about the simple way using css technique. Let us assume that a div with id “globalcontainer” is the whole container. Use the below css.
#globalcontainer {
width: 1000px;
margin: 0 auto;
}
By using the above css, the width of the container is set to 1000px, and the right-margin is set to “auto”, which aligns the page to center automaticaly.
Note: This technique may not work in internet explorer, if you don’t mention the doctype and meta content type. So, make sure that doctype and content-type is declared. Here is an example:
#globalcontainer {
width: 1000px;
margin: 0 auto;
}
….Body of the program goes here….