- Code: Select all
#container {
width: 770px;
margin: 0 auto
}
The second command, margin: 0 auto, basically gives our containing element an automatic margin on the left and right, thereby positioning the containing element in the centre of the browser window.
IE however, will need slightly different commands to make this work:
- Code: Select all
body {
text-align: center
}
#container {
width: 770px;
margin: 0 auto;
text-align: left
}
This will then centrally align the container in IE too. To prevent the text from centrally aligning too, we insert text-align: left into the container div.