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 trialBob Sutherton
20,160 Pointsproperty order
When doing CSS, does it matter what order you put the properties in? Is there a right and wrong way to do it or do you just start putting in properties as they occur to you?
For ex.
margin height font-style
or
font-style margin height
or does it not really matter at all?
3 Answers
James Barnett
39,199 PointsThe order of properties inside a rule doesn't matter for rendering, but it does matter for maintainability.
A good idea is to group your properties by function:
- Positioning
- Box model
- Typographic
- Visual
from: https://mdo.github.io/code-guide/#css-declaration-order
Andrew Youngwerth
10,188 PointsIn that case it doesn't matter. However if you had for ex: margin, color, font-style color - The last color property would be the one applied to your html.
ninyo
15,367 PointsIt doesn't seem to matter, but it helps to keep your property orders consistent with each selected elements. I generally like to keep my position and float properties at top, sizing towards the middle, and font adjustments on the bottom. Something like that will help keep organized.