How to horizontally center a div inside a div using css

Yes its very easy to center a block element inside other block element using simple css. Here is an example.

If you have following HTML code:


This is how we make innerDiv center horizontally.

.outerDiv{
width:100%
}
.innerDiv {
    width: 980px;
    margin: 0 auto;
}

if you are using IE8+ you have to do things like.

.innerDiv {
   display: table;
}
Scroll to Top