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 trialChenglu Li
1,380 PointsDo we need commas when setting width and padding?
When I watch the tutorials, I notice that sometimes the teacher will add commas when he sets width and padding in CSS, but sometimes will not. I try that and found out there is actually a difference if not using commas. Could anybody tell me more about commas? Thank you!
1 Answer
Justin Goldby
Full Stack JavaScript Techdegree Student 12,754 PointsI've never used commas when setting width or padding, simply space out the values for padding but do not forget your semicolon at the end of setting the width value and or your padding value(s) ;
David Shen
13,611 PointsDavid Shen
13,611 PointsI don't think you will need any comma to separate values in CSS. Unless you are using some mixins from preprocessors like SASS or LESS.
The shorthand of padding property can have from one to four values.
padding: 25px 50px 75px 100px;
top padding is 25px right padding is 50px bottom padding is 75px left padding is 100px
padding: 25px 50px 75px;
top padding is 25px right and left paddings are 50px bottom padding is 75px
padding: 25px 50px;
top and bottom paddings are 25px right and left paddings are 50px
padding: 25px;
all four paddings are 25px