Web Design | Web Development | Web Redesign | Game Development Application


How To Align Center Using Division In CSS

Posted in General,Tips & Tricks by markstephan on December 4, 2007
Tags: , , , ,

While converting the website design into HTML using CSS coding, we faces that how to centralized the website container. Many of the designers, try many things like to pass value like

#container {
padding-left:20%;
padding-right:20%;
}

or

#container {
margin-left:20%;
margin-right:20%;
}

This helps little bit but actual method is different and very easy to do it. Let me tell you the method.

Write like this or just copy it.
#container {
margin:0px auto;
}

why I’m using 0px and auto in margin because as you know the attributes for defining the 4 corners of the Web Page top right down and left. So I defined 0px for top margin attribute and auto set for other corners.  It automatically set the margin and the division tag comes to center.