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 How to Make a Website Customizing Colors and Fonts Organize CSS with Comments

Isaac Liao
Isaac Liao
908 Points

Space between codes

Sometimes we need to put space between codes like

~max-width: 940px~

sometime we can't have the space

~nav a, nav a:visited ~

How should we determine when a space should be used?

thank you

3 Answers

Armando Leon
Armando Leon
15,245 Points

There is usually a space between an property and its value, if only for readability. However, you don't actually need a space between:

max-width:940px;

is the same as

max-width: 940px;

However, you can't put a space between before a pseudo class. You can only write your second example as so:

nav a:visited { 
  /* property and value here */
}
Isaac Liao
Isaac Liao
908 Points

Noted!

thanks Armando

Jeremiah Shore
Jeremiah Shore
31,168 Points

FYI you also don't technically need character returns (new lines), so long as every statement ends with a semicolon.

e.g. the following will work, but has poor readability: div.content-area {color:black;background-color:orange;font-weight:heavy;}

The only time I have found something like that useful is when you need to put css in the style attribute. Even though typically a bad bad practice, I used it when I wanted to format my posts in a ticketing system I use for work. It made them easier to identify when going back, and cramming the css together makes copy/pasting the code easier in this odd situation.

Isaac Liao
Isaac Liao
908 Points

thank you for the useful tips!

I am having hard time memorizing the fixed format of property. I will try the ticketing system.