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 How to Make a Website Adding Pages to a Website Add Iconography

Pauline Hilborn
Pauline Hilborn
3,879 Points

Why did we add a background image to our CSS file here instead of simply adding an image source into our HTML?

In the video, we added a background image to get a twitter, phone, and mail icon to show up in our contact page. Why did we add it to our CSS as a background image instead of writing <img src="twitter.png"> into our HTML file?

4 Answers

Alexander Nortung
Alexander Nortung
6,930 Points

well i think it was easier this way if you wanted to add it with html you would still have to use padding and margin i also think that it is to learn you that you can do it this way and you learned the background-repeat,background-image and the diffrence between margin and padding

but of course you could add it through HTML :)

Michael Pavey
Michael Pavey
379 Points

I had this question too, and would love to learn Treehouse's response. But one point I noticed is that doing it this way makes the whole area (including the logo, text, and space in between) into a link.

Alina Cruceru
Alina Cruceru
1,129 Points

Nick's argument, as I understood it, was that it's best to put images that are mostly used for stylistic purposes (in this case, making the links look nicer) in the CSS file, while keeping images that actually serve as content in the HTML file.