Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    ubh is offline
    Regular Coder ubh's Avatar
    Join Date
    Apr 2008
    Portland, Oregon U.S.A.
    Thanked 15 Times in 14 Posts

    grouping length vs repeated CSS styles

    Ok here is where I always scratch my head, maybe some browser and cache/loading time guru could explain better or put some light on the situation.

    Cutting down on repeated styles is a good way to cut down on both your CSS file(s) size and your sites loading time. GREAT but this now begs the question of how far should I go to cut down on repeated styles?

    Take float:left; for example, this gets used a lot in my style sheet, now would it be wise to have a mile long grouping of each class and id that uses float:left; and then sum up the float:left; rule here.

    I only ask cause in some cases it seems the amount of chars uses to declare the grouping of classes and ids out weighs the amount of chars used over the amount of times I repeat the float:left; style in the whole sheet.

    So what am I making up for here then? What to do?

  • #2
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    United Kingdom
    Thanked 119 Times in 119 Posts
    well unless you're running on 28kb/s internet and have something in the region of >1mb CSS file then imo its' hardly worth worrying about

    personally I'll group similar classes/id where possible. i.e h1,h2,h3

    but any main "element" of my site I'll have in its own separate style, for readibility and future maintainability.

    i.e what if you did have every floated left element in one style, then you are required to change one or two of them to float:right?

    you'd have to go through the long list..find the one you want, cut it out, create a new class...etc

    just makes extra work unnecessary in my eyes


    Posting Permissions

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