By default a div
is a block element. This means it has . width: 100%;
margin: 0 auto;
will center the element but how can it do that if its width: 100%
.
For that matter!
Actually it has width: auto
, which for a block-level element is the full width of its container - but that's not 100% because otherwise padding would make it overflow - Niet the Dark Absol
CSS:
#footer { width: 200px; margin:0 auto;}
Also you could just text-align: center;