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

Hunter G
6,612 PointsFor better organization when using curly brackets in HTML & CSS . .
I wanted to know what people, especially seasoned developers, think about this placement method when using the curly brackets in both HTML and CSS. This is what a college professor of my taught us students how to write our code because it makes "easier" to interpret with the human eye and supposedly there is less chance of making an indentation error. I know it is all personal preference, but i'm curious about what others think or maybe they'll end up using this placement method instead? Please leave your comments below! :)
This is how Treehouse and many other sources teach how to place curly brackets..
@media screen and (min-width: 480px) { /* placing the opening bracket at the end of the element declaration */
a {
text-decoration: none;
}
#wrapper {
max-width: 940px;
margin: 0 auto;
}
#logo {
text-align: center;
margin: 0;
}
}
My college professor's method...
@media screen and (min-width: 480px)
{ /* placing the opening bracket a line below the element declaration */
a
{ /* the opening curly bracket is ALWAYS below the element.. */
text-decoration: none;
}
#wrapper
{
max-width: 940px;
margin: 0 auto;
}
#logo
{
text-align: center;
margin: 0;
}
}
Though these lines of code will do exactly the same style application to an HTML page, the brackets are positioned differently in both examples. The bottom example uses more rows due to the curly bracket being positioned below the element declaration but I feel it is easier to read the bottom code because the opening bracket is placed right below the element instead of looking for it at the very end of the line.
Personally I have adapted to this method and like it overall. When I see the normal method that most people use and teach it can confuse me a bit at first.
Anyways, I just wanted to share this on the forum. Thanks for reading! :)
2 Answers

Kristopher Van Sant
Courses Plus Student 18,830 PointsIn my personal opinion, I find your professor's CSS styling hard to read, and I certainly don't think it's the norm. That being said, I'd be careful of straying too far from normal coding conventions. These style standards and conventions exist for a reason, mainly for consistency and readability.
If everyone styled their code differently it would be very difficult to jump into someone else's code to add to it, make changes or debug. Keeping things consistent makes it easier for everyone. Just think if you were working on a project with someone who used a different styling than you did. How difficult would that be for you both to have to read each others code? Would it slow the project down? And if all that code was being used on the same project, the end result could be very messy, difficult to read, and very unpleasant for the next person who has to touch that code. This is why you see many companies using a Style Guide so that their code remains consistent within their organization.
I'd say stick with what the industry standard is, it'll make everyones lives easier. :)
Here's a few resources on style guides...
https://google.github.io/styleguide/htmlcssguide.xml
http://www.w3schools.com/html/html5_syntax.asp

kevinardo
Treehouse Project ReviewerI would guess that the professor have coded some C language and have a hard time leaving the bracket placement convention.
First time i see it used in a CSS code snippet :D running to the shower to clean myself
Hunter G
6,612 PointsHunter G
6,612 PointsHey Kristopher!
Thank you for answering, I appreciate your response. Yes you definitely make some valid points and reasons as to why my professor's positioning method is inefficient. To be honest he was quite a whack job anyways.. i'll do my best to stick with the standards! :)
Kristopher Van Sant
Courses Plus Student 18,830 PointsKristopher Van Sant
Courses Plus Student 18,830 PointsNo problem at all! Everyone has their own preferences and come from different backgrounds and experiences. Maybe his styling method works great for him and what he does. But yes, stick with the industry standards the best you can! It will be of more benefit to you in the long run. Happy coding!