> We've got three 'identifiers' to work with: id, name, and class. CSS > uses id and class.
CSS also uses element's name itself and can use variuos combinations, descendants etc. > Javascript uses id and name. So, to keep the issues > as separate as possible, I try to avoid using id for CSS. Popular JavaScript libraries let you use CSS selectors, so whatever you use in CSS to target elements works in JS too (and even more, because sometimes library can provide more methods than browser has implemented for CSS). > The problem > I've run into is that it's difficult to decide what 'class' a thing > belongs to until you've got lots of other things to compare it to. So > what I'm ending up doing in actual practice is to initially use id to > style elements as the UI emerges, then refactor to classes as the site > comes together. It's turning out to be a non-trivial exercise. That sounds strange. Maybe you just lack some practice? Two things to remember: IDs must be unique on the page, and you do not necessarily need classes (or id's for that matter) at all, there are other means to target elements. Lets say you want to target LI elements in some UL. You don't have to provide them all with classes or ids: just give some id to UL and then you can specify your LIs using "#myulid li" Likewise, to target paragraphs which got just after header you don't need to use id or class: "h2 + p" will work just fine. It is definitely worth spending some time with http://docs.jquery.com/Selectors - good grasp on these will help to simplify your code. Regards, Rimantas -- http://rimantas.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

