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

Do we really need a space after the colon in CSS?

Hi I see the tutorials include a space after the colon in CSS, I've never put one before and wondering if it's really a best practice? I find the space doesn't really help with readability anyway and it's just an extra character. I'm trying to change my habit to add a space but I keep forgetting. What do you think?

Thanks- Michele

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,862 Points

Hi Michele,

I feel it is just more of a coding preference and for readability. I know you said you find no difference, but I find it a little easier to read with the space. Although that may come from my writing/editing background, where a space after the colon is mandatory.

I don't think it matters at all whether you use a space or not, especially if you are the one working on it. When/if you minimize the CSS file for production, the space is gone anyways.

:)

Interesting, thank you Jason. I'm going to try and get in the habit of adding the space now.

It's really personal preference, but most people prefer to have a space after the colon just because it looks less cluttered.

Thank you Tate! Good to know. Yes I will try to get in the habit. :)