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 trialThania Abrahams
972 PointsOrdering in organising your CSS
CSS Colors: Under the colors, why does Nick move the nav color rule above the logo text when the logo text actually comes first?
General CSS: And in the general rules, why does he flip the wrapper before the anchor links? Is it because the wrapper is the broader selector? If that is so, if the broadest selector should come first, then why do the colors of links come after the header and the logo text?
/**************************************************
GENERAL
**************************************************/
body {
font-family: 'Open Sans', sans-serif;
}
#wrapper {
max-width: 940px;
margin: 0 auto;
padding: 0 5%;
}
a {
text-decoration: none;
}
/**************************************************
COLORS
**************************************************/
/* green header*/
header {
background: #6ab47b;
border-color: #599a68;
}
/* nav background on mobile*/
nav {
background: #6ab47b;
}
/* logo text*/
h1, h2 {
color: #fff;
}
/* links*/
a {
color: #6ab47b;
}
/* nav link*/
nav a, nav a:visited {
color: #fff;
}
1 Answer
Steven Parker
231,198 PointsI don't think Nick was concerned about the order in which things appear in the header, he was just organizing the styles that pertain to the header in one section under the comment. Remember that CSS itself is not affected by order unless two rules select the same element and with the same level of specificity. In that case, the one that comes last "wins".
And in the case of wrapper vs. anchor, the placement is not about broadest selection but about the category of things the styles are doing. Wrapper winds up in the general section, while the anchor links are grouped in the color section because that is what they are being used for.
Also remember that the organization is not a strictly "right way" vs. "wrong way" situation. Personal preferences - in this case, Nick's - will influence the actual order of things. I think the point of the lesson is to be mindful of order, not necessarily to do it just the way shown.
Thania Abrahams
972 PointsThania Abrahams
972 PointsThank you for taking such time to answer my question :)