SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    May 2010
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How long your .css files are?

    Inspired by RyanReese's post:

    http://www.sitepoint.com/forums/show...51&postcount=2

    I started to think how big/long my .css files are?

    I'm actually working on my portfolio (looks pretty simple, but I'm using huge amount of JavaScript and jQuery) and the .css file is about 500 lines long (excluding reset.css). CSS3, optimized (using the latest selectors etc.).

    Another one from my latest websites - small company's site is also around 500 lines (not optimized yet).

    I know that's not too important, but as a perfectionist I'm curious how long your css files are?

    Cheers!

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,301
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Depends on how big the site is, but I do go well over 500 lines on some sites, although I do break each declaration into a separate line, which I'm reconsidering at the moment.

    I prefer one style sheet over multiple ones, but I know others have a different approach.

    In the end, I would say it's not so much about how many lines of code you have, but about the size of the CSS file in KB. I've heard some opine that you should aim for a maximum of 12KB for the CSS file, but I don't know how many people subscribe to that view, and I know many style sheets go over that.

    EDIT: regarding long style sheets being hard to manage, I find that using a tool like Firebug makes it easy to find the relevant line for each declaration, so I never have trouble finding the right place in the style sheet (as long as there are line numbers in the editor).

  3. #3
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How long your .css files are?
    Good question

    I've never really thought about it that much before.

    Just having a quick look around the one I have created recently (for completed websites), they are typically between 500 - 700 lines and 10-15kb in size.

    I put each style declaration on a separate line as well - mainly for ease of readability.

    Managing the stylesheet is easy. I use Netbeans as my IDE and when I open a stylesheet it displays all the selectors in alphabetical order in the sheet's navigation window no matter what order they are in in the stylesheet - although I try to place them in alphabetical order as much as I can.

  4. #4
    SitePoint Wizard bronze trophy Black Max's Avatar
    Join Date
    Apr 2007
    Posts
    4,029
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    To me, file size is almost irrelevant except in extreme cases. I'm far more interested in being able to navigate through the CSS file with some facility. I've seen a bunch of techniques on how to structure CSS files for ease of use (I've listed some of them here), but I find that the best way for me to handle my sometimes-large and complex CSS files is to structure them the same way every time. That way I know what's going to follow what and I can work a bit more efficiently.

  5. #5
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree with Black Max. Of course are there may ways one could structure his/her stylesheet, but at the end it should be something you feel comfortable with, no matter what anyone else say.

  6. #6
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,484
    Mentioned
    182 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by copenmatt View Post

    I know that's not too important, but as a perfectionist I'm curious how long your css files are?

    Cheers!
    They are as long as they need to be to get the job done. No more no less

    Of course you want to rationalise as you go and not duplicate common styles but the css will need to be as long as it takes to get the job done. If that's 500 lines or 2000 lines doesn't really matter as long as the css is optimised as best you can and isn't wasteful or badly written.

    If the css is getting very large then it's probably time to re-think the design a bit (if that's within your remit).

    I have worked on some very large sites where each section is vastly different from what went before with only a few common elements between them. In those cases I split the css files into each section rather than having one massive css file. I separate the common elements into a structural file and then have section related css.

    I don't always agree with loading all the css for the whole site (on a very large site) as that makes the user wait too long on first page load and you never get a second chance to make a first impression.

    Also there's no point in trying to shave off 1 or 2k from your css file if you have about 500k of images scattered around the page when optimising one of those images would save more k than the whole css file.

  7. #7
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,816
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    On average, and not counting my comment on or spacing lines 80-120 lines. I don't know if that relates to what you are asking. I dont press return between declarations tho ( I hate scrolling) and I tend to group my rules a lot ( ie .: #head, .somerule p, li a, .somediv li a: hover{color:red}.

    I dont think it's something to worry about tho. For example I group certain rules because I am really being an Art Director ... #head, .somerule p, li a, .somediv li a: hover{color:red}, really means that I want the text of #head, .somerule p, li a, .somediv li a: hover to MATCH. As each rule name may be to be repeated here and there for other things , it may take less characters to make each, color declaration for example within its corresponding rule BUT then that means if you change the color.. you now have to hunt down each rule. I f you just wanted to separate #HEad from the others , for example.. you can look for the color and take #head out.. poof! that is worth a few extra bytes


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •