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
yishan bai
4,116 Pointscan'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>
yishan bai
4,116 Points@Marcin Lisewski
Thanks for your help, but it still doesn't work...
1 Answer
Tom Bedford
15,645 PointsHi 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.
yishan bai
4,116 PointsThank 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
marcinlisewski
19,839 Pointsmarcinlisewski
19,839 Pointstry add !important;