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

When setting a background in css why declare transparency?

I keep seeing this lately, and I don't understand it, in all my time of making sites I've never had to explicitly declare the background to be transparent - am I missing something? Why would anyone want to do this?

.some-class {
  background: transparent url('./images/picture.jpg') no-repeat;
}

1 Answer

It's just explicitly stating what is already the initial value for background color. If a background color isn't specified for an element, the browser should default it to transparent. Just just explicitly states that.

Kevin you're on fire hah! Ok, so it's kind of like a fail safe...