Categories

.NET (1) CSS (5) OOP (1) PHP (2) SQL (5) SQL Server (8) TSQL (1)

Wednesday, September 8, 2010

How to Centre a DIV Block Using CSS

Consider this structure.

<body>

<div id="wrapper">
</div>

</body>


CSS Property:

body {
    text-align: center;
    min-width: 600px;
    background:green;
}

#wrapper {
    margin:0 auto;
    width:600px;
    text-align: left;
    background:red;
    height:100px;
}




The technique will center the DIV because we are setting the margins to auto, web browsers are required by the CSS standard to give them equal width from both sides.

No comments:

Post a Comment