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! While you're at it, check out some resources Treehouse students have shared here.

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

General Discussion

Warner Cyr
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Warner Cyr
Front End Web Development Techdegree Graduate 21,047 Points

Trying 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
PLUS
Casey Antoine
Courses Plus Student 5,174 Points

Best way to center any element is to set

margin: auto;

Logan R
Logan R
22,989 Points

Simply change margin: 0; to margin: 0 auto; and it should center :)