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

HTML How to Make a Website CSS: Cascading Style Sheets What is CSS?

What is the point of the long gaps between the curly braces?

I keep seeing it typed as:

  footer {
    color: green;
  }

Why not type it as:

footer {color: green;}

It just looks much neater to me. I tested it and it still applies the color change to the footer, which is why I ask. Only reason I can think of is so you can add different rules, which if so, you can still add the indents afterwards. Is it just personal preference?

3 Answers

rydavim
rydavim
18,813 Points

Welcome to Treehouse!

I would say this mostly comes down to personal preference. Pick a method you like and be consistent. This has no effect on the output of your code.

Happy coding!

Cool, thanks for the fast reply :)

brandonlind2
brandonlind2
7,823 Points

It's simply more organized and makes it a lot easier to write additional code. If you end up needing to add additional code you can simply click in front of the first { and hit enter and start typing. If you write all your code like this footer { color: green;} you end up needing to click in front of the { and then hit enter to move the code down, then take your hand of the key board and click in front of the { again. The way you keep seeing it simply allows you to type faster, if you need to come back and add additional code.

I understand it might be faster, but to me it looks nicer. I'm still new to this though, so maybe it isn't necessary to have your code looking neat

Do you see how when you have several attributes like the img below and many html targets it makes sense to write it out in blocks rather than long single lines that may go off of your editor and cause you to have to scroll over.

p {
    font-family: cursive;
}

#carlyTitle {
    color: aquamarine;
}

img {
    max-height: 300px;
    max-width: 200px;
    border: dashed;
    border-color: orange;
    border-radius: 20px 25%;
}

.big {
    font-style: oblique;
    color: firebrick;
    outline-style: none;

}

An interesting side note: Once you start javascript, you have to place your brackets like this:

function correctBrac() {
    //stuff to do;
}

and NOT like this as in C programming.

function wrongBrac() 
{
    //stuff to do;
}

Once you are a paid programmer at a great company, they may have a style guide that enforces things like this.