Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
221,070 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.