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 CSS Basics (2014) Basic Layout Backgrounds: Size and Position

background-size: cover; vs background-size: 100%;

Hey everyone,

I have a question about

background-size: cover;

vs

background-size: 100%;

Do these commands do the same thing? Or is there a difference?

Thanks!

Fredrik Rönnehag
Fredrik Rönnehag
2,342 Points

cover = Scales the image to be large enough until the background area is completely covered by the image. Some parts of the image may not be in view within the area.

100% = Fills the area but all of the image is visible. It might screw with proportions though.

You can check an example here, https://www.w3schools.com/cssref/playit.asp?filename=playcss_background-size&preval=cover

Also more information about the css background-size, https://www.w3schools.com/cssref/css3_pr_background-size.asp

1 Answer

Thank you this also confused me.