Hi, I know that my question doesnt aim 100% at this group, but at least here are people that care for cross browser behaviour. Is there a guaranteed behaviour for elements having multiple classes? <div class="red blue">hello world</div> when div.red { background-color:red;} div.blue {background-color:blue;} it will be blue. <div class="blue red">hello world</div> will also be blue. So order in className will not matter. when I switch the lines in the css: div.blue {background-color:blue;} div.red { background-color:red;} it will be red in both cases. So is the order of the css definitions always relevant for the style of the elements? I noticed that adding or removing class name on runtime doesn''t change this behaviour. Even when the first css class is added later on the div will look always like the second defined css class So despite this being a bit odd to me (not the css definition but the element definition should infulence that imho), I wonder if all browsers behave the same here. Thanks Fabian _______________________________________________________________________ Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und kostenlos. Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=022222 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Fabian, The last style definition always wins from the the one that came before it, unless it is less specific. Like so: <div class="message">correct </div> <div class="message error">oops</div> div.message { color: black; background-color: green; } div.message.error { background-color: red; } In this example the order of the style definitions wouldn''t matter because div.message.error is more specific. -Thomas. On Jan 8, 2007, at 15:46 , Fabian Lange wrote:> > Hi, > I know that my question doesnt aim 100% at this group, but at least > here are people that care for cross browser behaviour. > > Is there a guaranteed behaviour for elements having multiple classes? > > <div class="red blue">hello world</div> > > when > div.red { background-color:red;} > div.blue {background-color:blue;} > > it will be blue. > > <div class="blue red">hello world</div> > > will also be blue. So order in className will not matter. > > when I switch the lines in the css: > div.blue {background-color:blue;} > div.red { background-color:red;} > > it will be red in both cases. > So is the order of the css definitions always relevant for the > style of the elements? > > I noticed that adding or removing class name on runtime doesn''t > change this behaviour. Even when the first css class is added later > on the div will look always like the second defined css class > > So despite this being a bit odd to me (not the css definition but > the element definition should infulence that imho), I wonder if all > browsers behave the same here. > > Thanks > Fabian > > ______________________________________________________________________ > _ > Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und > kostenlos. > Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=022222 > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
See "Cascading order": http://www.w3.org/TR/REC-CSS2/cascade.html#cascade "Finally, sort by order specified: if two rules have the same weight, origin and specificity, the latter specified wins. Rules in imported style sheets are considered to be before any rules in the style sheet itself." best, thomas Am 08.01.2007 um 15:46 schrieb Fabian Lange:> > Hi, > I know that my question doesnt aim 100% at this group, but at least > here are people that care for cross browser behaviour. > > Is there a guaranteed behaviour for elements having multiple classes? > > <div class="red blue">hello world</div> > > when > div.red { background-color:red;} > div.blue {background-color:blue;} > > it will be blue. > > <div class="blue red">hello world</div> > > will also be blue. So order in className will not matter. > > when I switch the lines in the css: > div.blue {background-color:blue;} > div.red { background-color:red;} > > it will be red in both cases. > So is the order of the css definitions always relevant for the > style of the elements? > > I noticed that adding or removing class name on runtime doesn''t > change this behaviour. Even when the first css class is added later > on the div will look always like the second defined css class > > So despite this being a bit odd to me (not the css definition but > the element definition should infulence that imho), I wonder if all > browsers behave the same here. > > Thanks > Fabian > > ______________________________________________________________________ > _ > Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und > kostenlos. > Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=022222 > > > >-- Thomas Fuchs wollzelle http://www.wollzelle.com questentier on AIM madrobby on irc.freenode.net http://www.fluxiom.com :: online digital asset management http://script.aculo.us :: Web 2.0 JavaScript http://mir.aculo.us :: Where no web developer has gone before --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Fabian Lange wrote:> I know that my question doesnt aim 100% at this group, but at least here > are people that care for cross browser behaviour.Spoofing subject doesn''t help (quite the opposite). :-/> Is there a guaranteed behaviour for elements having multiple classes?Yes, there is, the "C" in "CSS": "cascading". Read some CSS tutorial, any CSS tutorial, there should be special chapters about this (cascading, selector specificity, etc). For instance, the CSS spec: http://www.w3.org/TR/CSS21/cascade.html As for "cross browser" (seeing Thomas'' reply), keep in mind that Internet Explorer (until version 7) has trouble dealing with declarations like ".foo.bar" (it will treat them like ".bar" (the _last_ "class"). - -- Marius Feraru -----BEGIN PGP SIGNATURE----- iD8DBQFFol5jtZHp/AYZiNkRAlZjAKDtieAGd/AwTQ8CtEZsyPGYJdwO+ACg9oCx YQv9kKjc5wEPhEkbtmpjLWc=87Jz -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, thanks for all the answers. I found that Spec, but was unsure if its implemented cross browser the same way. Also the dynamic adding of css classes seemed for me not 100%. As it could also be : take current style, apply what has come additionally.. But it seems everything works here as I would expect it. I take your replies as confirmation. Thank you. Fabian -----Original Message----- From: grbounce-_Pkz0AUAAAB9-VKt0-RY8LHUELm10l3Y=fabian.lange=web.de@googlegroups.c om [mailto:grbounce-_Pkz0AUAAAB9-VKt0-RY8LHUELm10l3Y=fabian.lange=web.de@google groups.com] On Behalf Of Thomas Fuchs Sent: Montag, 8. Januar 2007 16:06 To: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails-spinoffs] Re: Javascript/CSS question See "Cascading order": http://www.w3.org/TR/REC-CSS2/cascade.html#cascade "Finally, sort by order specified: if two rules have the same weight, origin and specificity, the latter specified wins. Rules in imported style sheets are considered to be before any rules in the style sheet itself." best, thomas Am 08.01.2007 um 15:46 schrieb Fabian Lange:> > Hi, > I know that my question doesnt aim 100% at this group, but at least > here are people that care for cross browser behaviour. > > Is there a guaranteed behaviour for elements having multiple classes? > > <div class="red blue">hello world</div> > > when > div.red { background-color:red;} > div.blue {background-color:blue;} > > it will be blue. > > <div class="blue red">hello world</div> > > will also be blue. So order in className will not matter. > > when I switch the lines in the css: > div.blue {background-color:blue;} > div.red { background-color:red;} > > it will be red in both cases. > So is the order of the css definitions always relevant for the > style of the elements? > > I noticed that adding or removing class name on runtime doesn''t > change this behaviour. Even when the first css class is added later > on the div will look always like the second defined css class > > So despite this being a bit odd to me (not the css definition but > the element definition should infulence that imho), I wonder if all > browsers behave the same here. > > Thanks > Fabian > > ______________________________________________________________________ > _ > Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und > kostenlos. > Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=022222 > > > >-- Thomas Fuchs wollzelle http://www.wollzelle.com questentier on AIM madrobby on irc.freenode.net http://www.fluxiom.com :: online digital asset management http://script.aculo.us :: Web 2.0 JavaScript http://mir.aculo.us :: Where no web developer has gone before --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---