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

Kenny Parewijck
Kenny Parewijck
4,602 Points

Question about an id="logo" with wraps an anker element wich wraps a header. Background color not possible. why?

Hello

i was trying some stuff and I hit a wall.. I was searching online for an explanation but without succes. here we go:

HTML:

  <a id="logo">
    <h1>Kenny Parewijck</h1>
    <h2>Ondernemer</h2>
  </a>

CSS:

#logo {

background-color: orange; border: 3px solid red;

}

( I have put the ' before the # in this post here because else way it doesn't show the # here in the post)

Problem:

The background-color does not change. I can see a strange thing with the border though.. (only border in at the start). Can someone help me and tell me why the background color doesn't turn orange?

Thanks!

2 Answers

Hi Kenny,

your problem lies with the "a" element, because it is an inline element and wrapping the "h1 / h2" which are block level elements its width is collapsing and a few other things are clearly going on that I don't have the technical answer for.

The simple answer is just add "display: block" to the logo and its good to go!

I have set up a quick pen to show you the difference just simply comment out display block in the css and you will see your original result.

PEN HERE

Hope this helps Craig

Kenny Parewijck
Kenny Parewijck
4,602 Points

Oke Craig,

Thanks for the answer! Very clear right now.