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

Ludmila Totar
PLUS
Ludmila Totar
Courses Plus Student 615 Points

Do all the tags on CSS have to be in proper order?

Iv been trying to do all of my tags in somewhat chronological order but I noticed that it doesn't seem to make a difference is I don't. That being said, Id rather not waste the time if it doesn't make a difference in the long run. Does it matter?

Can you explain more what you mean by chronological?

2 Answers

Steven Parker
Steven Parker
231,261 Points

If by "tags" you mean the selectors of the rules, then the order is only significant when the rules apply to the same element(s). In this case a later rule will override an earlier one (assuming the same specificity).

But for selectors that apply to unique elements, the order does not matter.

Hi Ludmila,

CSS stands for Cascading Style Sheets. Cascading being the key word here. Style-sheets are read by the browser from top to bottom. If you were to set the same property with a different value like the example below, it will always take the latter value.

div {
    color: red;
}

div {
    color: yellow; /*This value will be overwriting the above value*/
}

Hope this helps.