I typically place the rules in my CSS in the same order as they are in the HTML. But what about global rules like how I format my input
,textarea
,p
,tr
,th
and stuff like that? Is there a convention on which order the rules should go in?
Obviously there are situations when the rules have to b开发者_开发百科e in a certain order to work.
I just put "global" properties of CSS in their own stylesheet all together. So for instance: put in tr, td, input, table,
etc in their own stylesheet and the rest of custom .classes and #divs in their own.
This simplifies it the best and keeps it organized.
Global CSS rules can go on a file (i.e. global-style.css) - these will apply to all pages. Specific CSS rules can go a separate file (i.e. login-style.css) - on this second file, you can override the default look-feel of the global CSS if desired.
You would only include the second file in the HTML files you need the different look-feel (from the global one)
I use one line per rule notation now, try to keep it organized and easy to read. It minimizes scrolling and it is easier to sort the rules that way.
精彩评论