Centering element with width declared
If you change your CSS , declare the width with a percentage, this method also works.
body {
background-color:#747474; } h1 { background-color: #0072B1; width:500px; text-align:center; color:white; margin:20px auto 0px; } p { background-color:#6BC5F7; width:440px; color:#333; margin:0 auto; padding:30px; line-height:1.5em; } |
body {
background-color:#747474; } h1 { background-color: #0072B1; width:60%; text-align:center; color:white; margin:20px auto 0px; } p { background-color:#6BC5F7; width:50%; color:#333; margin:0 auto; padding:5%; line-height:1.5em; } |