I typically use CSS classes defined in stylesheets for styles that I re-use often, and inline styles for CSS that I don’t re-use. Should all styles be in stylesheets? Stylesheets are cached by browsers which is helpful but it seems like that would make the pages a bit harder to work with.
If all styles are included in CSS files, should they reference the element name (like “#myElement { styles…}”) or use classes?
Thanks!
Generally, yes all CSS should be contained in a style sheet. There are a few instances where it is ok for CSS to show up inline (display:none, email css, etc).
There are a number of CSS methodologies out there that will help you discover best practices, I use this one:
http://smacss.com/
I prefer the use of classes in my CSS style sheets and reserve IDs for jQuery use.