Jump to content

Do property types have a specific order?


DizzyDan

Recommended Posts

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

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?

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

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

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

Just want to clarify
body {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

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

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 border
What do you mean by this?
Link to comment
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...