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

Order of Declarations (Ex. clear:both;)

The placement of rules in a stylesheet can possibly override previous rules, but how about declarations? Does the place of a declaration affect the style?

In the "footer" selector, Nick placed the "clear:both" declaration just after the second declaration which is "text-align:center," instead of the last declaration. I'm just curious if it's just personal preference or otherwise.

2 Answers

Hi Claudine,

no it doesn't really matter with the declarations. I would say it's better to keep it organised though.

For e.g.

This:

body {
font-family: serif;
font-size: 16px;
font-weight: bold;
height: 200px;
padding: 10px;
clear: both;
}

Is better than this:

body {
font-family: serif;
clear: both;
font-size: 16px;
height: 200px;
font-weight: bold;
padding: 10px;
}

You can see the second one is a bit messy and harder to read.

Joe

Thank you!