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

url() vs src=""

Why does background-image use url() instead of src="" like <img> does?

1 Answer

background-image uses url() because that is css code. Image tags in html (<img>) use src="" because that is the html code. They have similar purposes, but it's different code. You could no more use url() in html to access an image any more than you could use src="" in css to access an image.

Yeah I guess going through the material so quickly the languages start running together. Thanks!

Yeah I guess going through the material so quickly the languages start running together. Thanks!