{"id":270,"date":"2008-04-29T11:05:11","date_gmt":"2008-04-29T16:05:11","guid":{"rendered":"http:\/\/www.killersites.com\/blog\/2008\/how-to-organize-css\/"},"modified":"2008-05-19T10:52:50","modified_gmt":"2008-05-19T15:52:50","slug":"how-to-organize-css","status":"publish","type":"post","link":"https:\/\/www.killersites.com\/blog\/2008\/how-to-organize-css\/","title":{"rendered":"How to organize your css code: the \u00e2\u20ac\u02dckiller\u00e2\u20ac\u2122 css structure"},"content":{"rendered":"<p>I can&#8217;t stand articles that make you read two pages before getting to the point. With that in mind, let&#8217;s look at how I think css code should be organized.<\/p>\n<p><img src='https:\/\/www.killersites.com\/blog\/wp-content\/uploads\/2008\/02\/picture-2.jpg' alt='php-video-tutorial' style=\"float: right; margin: 15px;\" \/><\/p>\n<p><strong>In a nutshell:<\/strong> css code should be divided up into at least 4 separate pages:<\/p>\n<ol>\n<li>page-structure.css<\/li>\n<li>text-styles.css<\/li>\n<li>misc.css<\/li>\n<li>ie-styles.css<\/li>\n<\/ol>\n<p>How about we call this the &#8216;killer&#8217; css structure.<\/p>\n<p>\ud83d\ude42<\/p>\n<p>Before I go into the details of what each css file contains (if it&#8217;s not already obvious), I want to quickly cover WHY you might want to use this basic css structure for all your websites. <\/p>\n<p><!--more--><\/p>\n<p><strong>Why use the &#8216;killer&#8217; css structure?<\/strong><\/p>\n<p>It all comes down to one of the key reasons for using css in the first place: <\/p>\n<p><strong><em>Grouping code so that it is easier to update and easier to understand.<\/em><\/strong><\/p>\n<p>&#8211;<\/p>\n<p><strong>A common mistake<\/strong><\/p>\n<p>What I see over and over again, are web designers who put all their css code into one css file. This is indeed a big leap forward from using font tags all over your website &#8230; but by having only one huge css file, you&#8217;ve just created another big messy file to deal with. <\/p>\n<p><strong>To the point<\/strong><\/p>\n<p>Page-structure.css contains only css that defines the structure of your page. That is to say things like:<\/p>\n<p>&#8211; css code that sets whether the page is liquid of fixed.<br \/>\n&#8211; css code that sets whether the page is centered or justified left.<br \/>\n&#8211; css code that sets up the columns<\/p>\n<p>etc &#8230;<\/p>\n<p>I like to put the page structure code in its&#8217; own file because page structure css code is verbose (there&#8217;s a lot) and it can get a little black-magical. <\/p>\n<p><strong>What is black-magical css?<\/strong><\/p>\n<p>We all know that except for the simplest css layouts, it can be a real pain in the ass to get page layout to work in css. <\/p>\n<p>&#8230; Especially when floats and Internet Explorer bugs come into the mix. <\/p>\n<p>Anyway, the point is that css for page layout often contains nonsensical (black-magical) code to make it work. <\/p>\n<p><strong>OK, back to page-structure.css:<\/strong><\/p>\n<p>Another reason to have page-structure.css, is that once you&#8217;ve done creating your page structure, you rarely have to go into that code. So why bother having to scroll past it every time you edit other parts of your css? <\/p>\n<p>Personally I find myself tweaking css rules for text, color and images much more than I do page structure css. <\/p>\n<p><strong>Text-styles.css<\/strong> contains css code that only affects text. So I have all my header tags defined along with paragraph tags and classes. Again, when needing to edit some aspect of my text for the hundredth time &#8230; I just pop open the very clean and simple text-styles.css.<\/p>\n<p><strong>Misc.css<\/strong> is a style sheet that contains css code that does things other than page structure and text styling. This ultimately is a judgment call, but I typically put in formating for tables, forms, list or special id&#8217;s and classes.<\/p>\n<p><strong>IE-styles.css<\/strong> is of course, for your css rules that manage the Internet Explorer bugs. This all ties into the <a href=\"https:\/\/www.killersites.com\/blog\/2006\/ie-conditional-comments-video\/\">IE Conditional comments<\/a> strategy.<\/p>\n<p>You may need another ie-styles.css to deal with specific versions of IE. For example, you may have an ie6-styles.css. But thankfully, this is becoming less and less likely since IE6 use is falling fast. <\/p>\n<p>Thanks for reading,<\/p>\n<p>Stefan Mischook<\/p>\n<p>www.killersites.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I can&#8217;t stand articles that make you read two pages before getting to the point. With that in mind, let&#8217;s look at how I think css code should be organized. In a nutshell: css code should be divided up into at least 4 separate pages: page-structure.css text-styles.css misc.css ie-styles.css How about we call this the &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,4,9],"tags":[104,103],"_links":{"self":[{"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/posts\/270"}],"collection":[{"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/comments?post=270"}],"version-history":[{"count":0,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/posts\/270\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/media?parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/categories?post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/tags?post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}