Background Header Color Height

I’m trying to figure out WHAT ELEMENT I need to style so im able to set the height of the background color in the header. I want a black background in the header. These are the elements within the header:

  1. an h1
  2. a nav with 7 a href links
  3. an img

Of note:

  • I have set the image to position: absolute. I also want apx 15px above and below of the image
  • I floated the img left already

Again, of those three elements, which one do I choose to use in CSS to style so I can create the height of my black background?

Thanks in advance!!!

Are the elements you mention contained in a <header></header>? If so, you should be able to set the background-color of the <header></header> element to black. You’ll have to give the header a height property as well.

header {
  height: 100px;
  width: 100%;
  background-color: black;

Hope this helps!

1 Like

Yes! that did work. Thanks!

I almost always struggle to figure out how many levels of nestings I need to type in css to style an element. and the nav can be a nightmare for me because theres always at least three elements creating the nav. but, yes, your reply did work!

1 Like