WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] clean style.css? (5 posts)

  1. oldfish
    Member
    Posted 5 years ago #

    i am starting with the default theme and slowly modifying my site to the look i want. looking at the style.css file included it appears that there is a LOT of repeated code in the multiple sections.

    for example in page element, the following is repeated in both sections

    background-color: white;
    border: 1px solid #959596;

    Is this really necessary, and if not, does anyone have a cleaned up style sheet that excludes it? I can't imagine why I need both, but maybe there is something I am missing.

    thanks

  2. Saurus
    Member
    Posted 5 years ago #

    Code that refers to the SAME area of your template can be shortened via "css shorthand", but it must refer to the exact same area. Since you have not included a link to your site it is difficult to determine what can be shortened and what cannot.

  3. oldfish
    Member
    Posted 5 years ago #

    well it's the default theme, so i figured you all had a copy.

    I guess I will clarify the above example. There are several sections to the style.css file. There is a typography section for all the lovely text and background formatting. There is also a structure section that deals with the padding, margins, position, etc.

    in typography we have this:
    #page {
    background-color: white;
    border: 1px solid #959596;

    text-align: left;
    }

    in structure we have this:
    #page {
    background-color: white;
    margin: 20px auto;
    padding: 0;
    width: 760px;
    border: 1px solid #959596;
    }

    As you can see there is a bit of repetition with the CSS. That's just one example among many. Is there a reason that would be there other than to create a nightmare for updating the CSS?

    I can strip it all out no problem, but if someone has a cleaner version it would make things a bit easier as the file is nearly 700 lines long, and tracking down redundancies kind of sucks.

  4. zeniph
    Member
    Posted 5 years ago #

    No spedific reason for it being that way - just how the original author decided to write it back in 2005 - far as I know its not really been updated since. By segregating it into logical sections he's also unfortunately left some redundancy and duplication within it.

    Just because wordpress ships with it as default doesnt mean anything about it being best practice for CSS (though there's nothing technically wrong with doing it that way).

    Do a search - theres several variations and improvements on it that might suit your purposes.

  5. oldfish
    Member
    Posted 5 years ago #

    thanks guys that answers it for me. i know the redundant bits equate to a fraction of a fraction of a second, but somehow i feel better being rid of them.

    i figured they could go, but had that nagging "what if" thought.

    zeniph- i have done a few searches and looked at several templates. you're right, there's a lot out there.

Topic Closed

This topic has been closed to new replies.

About this Topic