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 trialLudmila Totar
Courses Plus Student 615 PointsDo 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?
2 Answers
Steven Parker
231,269 PointsIf 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.
Shaun Kelly
35,560 PointsHi 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.
KRIS NIKOLAISEN
54,971 PointsKRIS NIKOLAISEN
54,971 PointsCan you explain more what you mean by chronological?