Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Warner Cyr
Front End Web Development Techdegree Graduate 21,047 PointsTrying to center header image on page
<!DOCTYPE html> <html> <head> <title>Star Plumbing</title> <link rel="stylesheet" href="style.css" media="screen"> </head> <body> <div class="main-wrapper"> <img src="img/header.jpg" class="main-header"> </div> </body> </html>
main-wrapper {
max-width: 100%; }
.main-header img { display: block; margin: 0; padding:0; width: 980px; height: 339px; }
2 Answers

Casey Antoine
Courses Plus Student 5,174 PointsBest way to center any element is to set
margin: auto;

Logan R
22,989 PointsSimply change margin: 0;
to margin: 0 auto;
and it should center :)