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 trialTobi Ogunnaike
2,242 PointsHow come this works without the correct syntax?
I typed
body { background-color: red }
i.e. without the semi-colon (;) after 'red'
and the background color changed to red? When is the semi colon necessary?
Thanks
1 Answer
yannverreault
12,599 PointsIt is needed to separate your properties. Since you only have one property inside your declaration, it doesn't change anything. If you add more than one property inside your declaration, it wouldn't work.
You can test this by using this code:
body { background-color: red font-size: 16px }
You will notice that it's not functionnal.
To make sure, always use the semicolon.
Tobi Ogunnaike
2,242 PointsTobi Ogunnaike
2,242 Pointsthanks Yann, your explanation is very clear.