This forum is now read-only. Please use our new forums at discuss.codecademy.com.

CSS: An Overview Forum

View Course » View Exercise

176 points
D0e86371794a416f873bf883c33197ae?s=140&d=retro
Submitted by
jayess99
over 4 years ago

the brackets in CSS

why are the brackets in CSS separated from the property and value? I've found that the code works ok if it's all put on the same line. Doesn't make any difference, but there must be some reason you guys do it like that. Explain, please. thanks. js


0 votes

Best answer

permalink

do you mean like this?

p {
    color: red;
 }

instead of this: p{ color: red; } ?
If that's case, it's just a preference. It doesn't make any difference to the code. But it makes all the difference when you go back 6 months from now to try to fix or change something and you have 1000 lines of code to search from.

Whatever it is, find your way and stay consistent.

2946 points
5533b41186f55278520000c6_295543857
Submitted by
tony de araujo
over 4 years ago


0 votes

permalink

Yep, @Tony is absolutely right; the computer sees no difference between the two, but we format it like that for human readability. In fact, a lot of times people will write their CSS file, and then make a minified (a smaller, condensed and essentially unreadable) version of it to upload to their website to make the site load faster.

2200 points
530c059a80ff3328610007df_714652390
Submitted by
Haley
over 4 years ago