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

Design

How to confine a particular background-image to only one page of a website?

I have built the three-page website pursuant to the course with Nick. I would like to have the body of the index.html page display a certain image-background and leave the other two pages, the about.html and contact.html, with only a background color. What code do I write to confine the particular background-image to only the index.html page of my website? Thank you.

2 Answers

create new class and add on index.html body tag, and set the background-image you want

Joshua Watson
Joshua Watson
17,373 Points

Hello Chris,

You would add a class or id to your <html> tag as such: <html id="index">. Then you can add a background with css using the property bacground-image: url(./img/...).

Hope this helps, Joshua Watson