DizzyDan Posted November 22, 2010 Share Posted November 22, 2010 In CSS does it matter the order the property types are listed?Example.CSS1 body {color: red;top: 100px;text-align: left;float: left;} CSS2 body {float: left;color: red;top: 100px;text-align: left;} Is CSS1 gonna show up different any where than CSS2?I just put random properties in there but are there some property types that might need to be listed in order? Link to comment Share on other sites More sharing options...
ApocalypeX Posted November 22, 2010 Share Posted November 22, 2010 In CSS does it matter the order the property types are listed?Example.CSS1body {color: red;top: 100px;text-align: left;float: left;} CSS2 body {float: left;color: red;top: 100px;text-align: left;} Is CSS1 gonna show up different any where than CSS2?I just put random properties in there but are there some property types that might need to be listed in order? I've never heard of there being a specific order, but it has come across my mind. When I do my CSS I tend to assign background/color first, size, position/box model, sometimes I switch it up but I never notice any differences.I'm interested in this. Link to comment Share on other sites More sharing options...
jeffman Posted November 22, 2010 Share Posted November 22, 2010 Some combined rules, like margin, interpret values in a certain sequence, but the order of individual rules doesn't matter (unless the same rule is defined twice, in which case the second overrides the first).For your own sanity, it might make sense to group similar kinds of rules together, like display rules at the top, dimensional rules after that, color rules next, background rules, etc. -- and then do the same thing in every ruleset. Link to comment Share on other sites More sharing options...
DizzyDan Posted November 22, 2010 Author Share Posted November 22, 2010 Some combined rules, like margin, interpret values in a certain sequence, but the order of individual rules doesn't matter (unless the same rule is defined twice, in which case the second overrides the first).For your own sanity, it might make sense to group similar kinds of rules together, like display rules at the top, dimensional rules after that, color rules next, background rules, etc. -- and then do the same thing in every ruleset.Thanks, I dont randomly slap them on for each element! Though i could see how that might have someone leaving in a straight-jacket. I do use a "general" order that works for me. just wanted to make sure the order didnt matter.Just want to clarify(unless the same rule is defined twice, in which case the second overrides the first). body {color: blue;color: green;color: red;} The color would be red Link to comment Share on other sites More sharing options...
ApocalypeX Posted November 22, 2010 Share Posted November 22, 2010 Just want to clarifybody {color: blue;color: green;color: red;} The color would be red Yes, but only if the browser supports that styling.E.g.body {background: #000;background: -webkit-gradient(linear, left top, left bottom, from(#91edec), to(#FFF)); background: -moz-linear-gradient(top, #91edec, #000);} IE6 would display #000safari, chrome etc (webkit) display a blue and white gradientmozilla and gecko browsers display a blue and black gradient Link to comment Share on other sites More sharing options...
ShadowMage Posted November 22, 2010 Share Posted November 22, 2010 The only thing I've heard that matters is the order in which you define styles for the various pseudo classes of anchors. The order for that is:a:linka:visiteda:hovera:activeI can't verify that this is true, but I've seen a couple people on this forum mention this before. Link to comment Share on other sites More sharing options...
thescientist Posted November 22, 2010 Share Posted November 22, 2010 and border Link to comment Share on other sites More sharing options...
DizzyDan Posted November 22, 2010 Author Share Posted November 22, 2010 Yes, but only if the browser supports that styling.i was going for more the concept, not so much the styling.The only thing I've heard that matters is the order in which you define styles for the various pseudo classes of anchors.This is what actually sparked my question.and borderWhat do you mean by this? Link to comment Share on other sites More sharing options...
ApocalypeX Posted November 22, 2010 Share Posted November 22, 2010 border-top:#000 1px solid;border:#FF0000 10px solid; Link to comment Share on other sites More sharing options...
thescientist Posted November 23, 2010 Share Posted November 23, 2010 border-top:#000 1px solid;border:#FF0000 10px solid;I meant more in that certain border properties will not work without other ones present. Technically not an order issue, but similar.http://www.w3schools.com/css/css_border.asp Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.