CSS has been part of the web design backbone since ages until now and still getting better. When we spend huge amount of time developing, why not pay some attention on keeping things organized? Here we will try to develop CSS with a better approach.
.
A small section at the start of your CSS file where you define few details like Author, Version, Description.... Here is how it could look like:
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* Filename: grid.css
* Version: 1.0.0 (2007-09-21) YYYY-MM-DD
* Website: http://site.com/
* Author: Name
* Description: Handles the site layout.
== STRUCTURE: ==============================
* Page width: 950 px
* Number of columns: 3
============================================ */
Building versions of your CSS file helps you refer to your previous code or even restore an old one if required by any chance. So, keeping this snippet in the above code definition is a better practice.
* Version: 1.0.0 (2007-09-21) YYYY-MM-DD
Well, this is not for others but for you. If you need to have a better understanding on whatever you have coded and not get confused when you look at few thousand lines of CSS, go with this...
As I said above... if you are kind of person working on CSS files of a few thousand lines, this will be your best friend from now on. This is something similar to the HTML anchoring within the same page. The basic idea in CSS is that you will be adding commented sections with a unique character prefix for a quick search. You will have these unique named sections defined under your code definition so that you even get an overview of all the sections defined in that particular CSS file. Here is how it goes in the CSS file: Your Code Definition (header of the CSS file)
== INDEX: ===================================
_header : Site Heading
_rightnavi : Right Navigation
_accordion : Accordion Menu
============================================
Following CSS definitions You will be defining such anchors at the start of every section and also define the same in the code definition as above. When you need to get to a particular section, you will simply search for one of the anchors from the above index and your editor will take you straight to the section.
/* _header <the anchor>
==========================================*/
#header{ <attributes> }
#header .logo{ <attributes> }
. . . <long long list of your CSS definitions>
/*
_accordion
==========================================*/
. .
<long long list of your CSS definitions>
We now have a lot of CSS frameworks too popping out. CSS frameworks have both advantages and disadvantages. Read SmashingMagazine's article on CSS frameworks. For now, we will follow some advantages of CSS frameworks within our code. Your CSS can be broken down into different files like:
This way, you will have shorter code in each file which is more accessible. You will only have a base CSS file which will be included in your HTML and the above abstracted CSS files will be imported within your base CSS file using the @import url("filename.css");
.
Well... this is what we have been following in our projects and really feel much better with these standards. Hope this article has been informative to you. If you have any more ideas on this approach, please share below.
Comments
Hallo
In my gallery instalasion i see this problem
Required Extensions
curl is loaded. json is disabled.Please load the required PHP extensions in your php.ini before you continue.
my personal favorite of all the posts in df! :)
Hello some interesting information. I add to my favorite.
CSS "Cascading Style Sheets" Lessons
css list style Properties and examples -- http://css-lessons.ucoz.com/list-css-examples.htm
Spasibo!!!!!
Why not using a backend code to compile all the CSS' file contents into one CSS stream and send it to the requesting browser....
this will minimize HTTP requests and deziners will also attain simplicity.
in my current project where i am building a framework for all future website developments for a fortune 500 giant, i am just calling a backend function that writes in everything including the JS, Moo Framework, CSS, etc making the number of HTTP requests minimized to the max
Yes you should keep your CSS in one file to minimize the number of HTTP requests to speed up the page display. You could aggregate them later in one file using dynamic code in your section.
Multiple css files mean multiple http request which results in longer loading times. importing all the files in the standard css file makes no difference
I've started using the header information for my FLAs. Its just as helpful, digging into someone else's FLAs can be a nightmare. I changed website to "live URL", so if someone pops open a fla, they can see which page it's been embedded on.
@veerendra - its not "calling four cs sheets for different elements". We are just breaking the main file into different files for better understanding.
All these files are included inside your base CSS file + your base CSS file will be included in your HTML.
Indirectly all the CSS files are included but are somewhat hidden...
Post new comment