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

HTML

stephanie harrison roberts
stephanie harrison roberts
1,713 Points

adding in a background header image

Im trying to add in a background image into just the header no the whole page, but when i do its like the top nav sits below the whole image, and i want the image to sit behind whats already there. Ive put the html here, could someone point me in the right direction with regards as to what to add?

Thanks x <header> <div class="color-bar">color-bar</div> <div class="topnav"> <a class="active" href="#home">Home</a> <a href="#news">About</a> <a href="#contact">Contact</a> <a href="#classes">Classes</a> </div> </header>

2 Answers

Adam Beer
Adam Beer
11,314 Points

There are 2 ways. Inside the Css use the element id or class property. Like this.

#example {
   background-image: url("path");
}

or in Html inside the img or input tags use src attribute

<img src="path" alt="">

If the image is on another level then use "../". Hope this help.

Adam Beer
Adam Beer
11,314 Points

Your welcome! Happy coding!