25JulCutting down on CSS size

I did some cosmetic surgery on the site and managed to cut down the size of the CSS from 21K to 17K to 12K.

Mostly I did this by removing classes I didn’t use and more importantly by avoiding to use declarations like “font-family”, “font-size”, “margin-left”, “margin-right”, “padding-left”, “padding-right”, “background-color”, “background-image” etc, as much as I could.

Background

For example by changing the following:
background-image: url(bodybg.gif);
background-attachment:fixed;
background-color: #B53500;
to:
background: #B53500 url(bodybg.gif) fixed;

Margins and Paddings

The same thing can be done with margins and padding indicators:
padding-top: 10px;
padding-right: 0;
padding-bottom: 20px;
padding-left: 20px;
can be written like this:
padding: 10px 0 20px 20px;
Keeping in mind that the order start from the top in a clockwise direction:
TOP - RIGHT - BOTTOM - LEFT

Fonts

Fonts can be simplified as well:
font-weight: bold;
font-style: italic;
font-size: 12px;
font-family: times, sans-serif;
Can be simplified to:
font:bold italic 12px times, sans-serif;

Unnecessary Spaces

Another good size reducing trick is, instead of using multiple spaces to indent your code lines, just use tabs.
table
??{
????border-collapse: collapse;
??}

Using tabs reduces the number of characters need for indenting, from 8 to 3 in this case. This may not sound much at first but as your project gets bigger and so with it your CSS files, the difference will be dramatically quite notable.

  1. 1 Shade Windows Vista Mozilla Firefox 2.0.0.11 26 Jul 2004


    I think you’re a geek.

    -Shade

  2. 2 Wendy Windows Vista Mozilla Firefox 2.0.0.11 26 Jul 2004



    I wouldn’t say all that unless he was pasty white from lack of sun. =p

  3. 3 Bob Windows Vista Mozilla Firefox 2.0.0.11 27 Jul 2004


    does all that stuff really need to be posted?

  4. 4 RauL Windows Vista Mozilla Firefox 2.0.0.11 27 Jul 2004


    It is his site…

  5. 5 TCorp Windows Vista Mozilla Firefox 2.0.0.11 27 Jul 2004

    Well Bob,
    …I think the question you should ask yourself is, should you comment on a topic when you don’t know what it is about? And thank you, Shade, I hold that title with pride! *puffs chest out*

  6. 6 Bob Windows Vista Mozilla Firefox 2.0.0.11 27 Jul 2004


    i know what its about. ive been shorthanding my code for a long time. i just didnt see the point.

  7. 7 Shade Windows Vista Mozilla Firefox 2.0.0.11 27 Jul 2004


    His petty victories over small CSS irritants amuse him, and makes him feel warmth within his tappity soul…

    No, wait, that’s me!

    -Shade

    PS - TCorp:

    “The big delete my cookies on this computer button”

    HA HA HA!

  8. 8 TCorp Windows Vista Mozilla Firefox 2.0.0.11 27 Jul 2004


    Wow…from the Eminem forum AND knows CSS…what a rare and oddly intriguing combination…
    ^.o

  9. 9 TCorp Windows Vista Mozilla Firefox 2.0.0.11 27 Jul 2004

    Shade,
    The title of the button was already pretty long, so i though, why not make it amusing if I have to stick with a long title anyway….?

  10. 10 Bob Windows Vista Mozilla Firefox 2.0.0.11 27 Jul 2004


    isnt it?

  11. 11 RauL Windows Vista Mozilla Firefox 2.0.0.11 28 Jul 2004


    I remeber doing this on some community site I was a member in, since they didnt allow you to link CSS files and they gave you a characters limit on the part where you could type your HTML, you had to put everything together, like on the scrollbars code…

    this
    scrollbar-3dlight-color:#1a1a1a;
    scrollbar-arrow-color:#00C000;
    scrollbar-face-color:#1a1a1a;
    scrollbar-highlight-color:#2a2a2a;
    scrollbar-darkshadow-color:#2a2a2a;
    scrollbar-shadow-color:#2a2a2a;
    scrollbar-track-color:#1a1a1a;

    would be..

  12. 12 RauL Windows Vista Mozilla Firefox 2.0.0.11 28 Jul 2004


    Oopz.

    --style tag here--
    body{
    scrollbar-track-color:#1a1a1a;
    scrollbar-highlight-color:#2a2a2a;
    scrollbar-3dlight-color:#1a1a1a;
    scrollbar-darkshadow-color:#2a2a2a;
    scrollbar-shadow-color:#2a2a2a;
    scrollbar-arrow-color:#404040;
    scrollbar-face-color:#1a1a1a}
    –style tag here lol—

  13. 13 TCorp Windows Vista Mozilla Firefox 2.0.0.11 28 Jul 2004

    Raul,
    …are you talking about style manipulation via code injection….? And in order to overcome the field limit in the database, you basically wrote the entire makeup of the object (body) in one line?
    (I had to edit your post, since it was stretching out the layout)
    btw, scrollbar isn’t really valid CSS code (only supported by IE5.5+), so we don’t use that :-P

  14. 14 Bob Windows Vista Mozilla Firefox 2.0.0.11 28 Jul 2004

    tcorp
    is there supposed to be a bg image in your new CSS or did you take it out? i wasnt sure because the background in firefox on my laptop shows up white. it showed up before but i know you changed it and now its not. i looked in your css and saw that there is supposed to be an image.

  15. 15 TCorp Windows Vista Mozilla Firefox 2.0.0.11 28 Jul 2004


    The body background had an image but it was commented out a few days ago.
    The #container has a very subtile mosaic background comprised of #FFFFFF, #FCFCFC, #FBFBFB and #FAFAFA. The colors don’t show up on the LCD display of my laptop either but they look fine on my TFT display and CRT monitor. Maybe I’ll darken it a bit later…

  16. 16 RauL Windows Vista Mozilla Firefox 2.0.0.11 28 Jul 2004


    Lol, sorry about that, but yeah thats what i used to do before, putting the ; between each value and keep them in the same line instead of hitting enter each time I typed one.

  17. 17 Bob Windows Vista Mozilla Firefox 2.0.0.11 29 Jul 2004

    ahh
    okay, that makes sense.

    i used to write all my values on the same line as well but i found it easier to divide and read when i was editing/debugging, if i wrote them each on their own lines.

    this is hybrid, btw. lol

  18. 18 TCorp Windows Vista Mozilla Firefox 2.0.0.11 29 Jul 2004

    hybrid?
    Well, there goes your theory that you don’t spend any time here and my theory that “bob” actually may know a bit of CSS…I should’ve known it was you since you’re the only person ever to search for “/designer” on my site..Here’s what you’re looking for…

  19. 19 TCorp Windows Vista Mozilla Firefox 2.0.0.11 29 Jul 2004

    btw, Shade…
    ….if you’re reading this, remind me to tell you friday on AIM how to solve our bbcode-for-php-tag paradox. I found a way to do it right ! :-)

  20. 20 Bob Windows Vista Mozilla Firefox 2.0.0.11 29 Jul 2004


    lol, your news blog always has something interesting to read so i had to stop by. and i do know css. im currently writing the css for my website.

  21. 21 Bob Windows Vista Mozilla Firefox 2.0.0.11 29 Jul 2004


    ok, i see the mosaic bg now. i just put firefox on my work computer and it shows up with FF but now with IE, even though it should have, judging by the monitor im on. IE = s*it.

  22. 22 TCorp Windows Vista Mozilla Firefox 2.0.0.11 29 Jul 2004

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <?
    echo "booya!!";
    phpinfo ();
    function test()
        {indented;
            //indented again
            code;
            code;
        }
    ?><a href="http://magnablog.0xtc.com/">tcorp</a>clear text and not formatted in html</a> <!-- where the heck is this last span tag coming from ? -->

Leave a Reply




flickr stream

California ufo / drone (taken  at Lake Tahoe using camera phone) 1 california ufo / drone (picture taken by police) 26022008075 california ufo / drone (raw picture) 4 Drone 2 - blurry California ufo / drone Terrometer california ufo / drone (raw picture) 5

Random Gallery Image

Tunnel K2 Side K2 Side Frankfurt Messe Building Pond at MesseTurm Drive To Niagara Falls The desert A Drop Of Water

Most Recent

Bush no-country-mcain.jpg lego-mohammed.jpg mbaside.jpg

Calendar

August 2008
M T W T F S S
« Jul «-»  
 123
45678910
11121314151617
18192021222324
25262728293031