Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Matthew Keys
1,922 PointsExplanation of the slash after the image position
Can someone please explain to me why you need to put a slash after the image position (center / cover)?
1 Answer

Jason Anello
Courses Plus Student 94,592 PointsHi Matthew,
This is a syntax requirement to remove ambiguity that would occur without it.
background-position
and background-size
can both accept some of the same types of values. For example, percentages and lengths.
Imagine the following background shorthand was used:
background: 30% 80%;
This can be interpreted multiple ways if we didn't have that forward slash syntax requirement. Are both of those values for the background-position? Are both for background-size? Is one for background-position and the other for background-size?
To remove this uncertainty, it was decided that background-position would be first, then a forward slash, and then the background-size.
This syntax also means that it's not possible to specify the background-size without also first specifying the background-position using the shorthand.
Going back to the earlier example, because the browser does not see a forward slash followed by values for background-size, it knows that the 30% 80% is for background-position. There is no other way to interpret it.