How to center a header image

center, css, image

Solution

CSS for `header`

width:100%;
text-align:center;

CSS for your `img`

display:inline-block;
margin: 0 auto;

See example here

That said, merely having `text-align:center;` on your `header` should be find, as in here

Problem

I have a problem. The answers to other people questions didn't solve my problem. It's about image in my header, here's the code: HTML ``` <div id="site"> <div id="header"> <img class="center" src="http://i.imgur.com/jfDhpP5.png"/> </div> <div id="mainNav"> <li><a href="#">one</a></li> <li><a href="#">two</a></li> <li><a href="#">three</a></li> <li><a href="#">four</a></li> </div> </div> ``` CSS ``` #container{ width: 1000px; margin: 1em auto; } #header{ display: block; width: 1000px; margin: 0 auto; } body{ background-color: grey; color: black; font-family: sans-serif; } img.center{ text-align:center; margin: 0 auto; padding:0px; } ``` I also try this: ``` div#pictures { text-align: center; } ``` also not working... checked in firefox and IE, the newest versions.... o.O Please help!

Original source