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

CSS

Owa Aquino
Owa Aquino
19,277 Points

How to make your image centered?

Hey guys! maybe you can help me out in here. I have an image(logo) needed to be centered, but seems to me its not working.

HTML

<header>
    <a href="#" id="logo_owa">
        <img src="img/_heading/logo_owa.png" alt="Owa Logo" >
    </a>
</header> <!-- END OF HEADER -->

CSS

#logo_owa img{
    display: block;
    margin: auto 0 30px;
    max-width: 198px;
}

1 Answer

Erik S.
Erik S.
9,789 Points

Hi Owa, At the moment margin: auto is applied to the top of the element. (When you specify three values, then the order is margin: top, right/left, bottom). Please try: margin: 30px auto; to see if you achieve the result you would like.

Owa Aquino
Owa Aquino
19,277 Points

This works. Thank you very much Erik. :D