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

can't change background color despite adding declaration into #logo

hi, i have added

#logo{
    text-align:center;
    margin:0;
    background-color:orange;
}

please note the 3rd declaration, but the background color doesn't change at all, while the other two declaration(text-align, margin) work fine, can anyone help plz??can't figure out the reason. Thx a lot!!!

  <a href="index.html" id="logo">
       <h1>Sarah  B</h1>
       <h2>Designer</h2>
      </a>

@Marcin Lisewski

Thanks for your help, but it still doesn't work...

1 Answer

Hi Yishan, your #logo element a is an inline element by default. If you had other inline content inside it then a background color would show for that content. However as both nested elements (H1 and H2) are block level elements the background is not showing up.

You can solve this by making the a element a block (or inline-block) as well, as in this codepen example. You may want to set a width depending on the design you are going for.

Thank you so much Tom!!i hope when the course progresses,it will touch on these topics, just couldn't figure out the reason.this matter has bothered me for a few hours...such a relief, now i can move on...thanks again