Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6713829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:25:33+00:00 2026-05-26T08:25:33+00:00

I found this CSS minifier ( http://www.lotterypost.com/css-compress.aspx ). There is a section at the

  • 0

I found this CSS minifier (http://www.lotterypost.com/css-compress.aspx). There is a section at the bottom of that page labelled “What does the CSS Compressor purposely NOT do?” There are four things, two of which I couldn’t understand why they might be destructive:

Combining individual margin, padding, or border styles into a single property.

  margin-top: 10px; 
  margin-right: 0; 
  margin-bottom: 8px;
  margin-left: 30px;

Becomes

  margin: 10px 0 8px 30px;

And combining styles for the same element that are specified in different style blocks.

#element {
   margin: 0;
}

#element {
   color: #000000;
}

Becomes

#element {
   margin: 0;
   color: #000000;
}

I think CSSTidy does both of these. Is the web page above correct? Are there situations where these types of minification might be a problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:25:33+00:00Added an answer on May 26, 2026 at 8:25 am

    I’m the developer of the CSS Compressor that is the subject of this question (http://www.lotterypost.com/css-compress.aspx), so I’ll elaborate with an example of how a compressor can break the CSS cascade if a tool aggressively re-writes it.

    There are many ways of targeting elements in a style sheet, and because a CSS compressor does not have intimate knowledge of the page’s DOM structure, classes, ids, etc., there is no way for a compressor to know if an optimization that crosses bracketed definitions will break or not.

    For example, a simple HTML structure:

    <div class="normal centered">
        <p>Hello world.</p>
    </div>
    

    And some CSS:

    div.normal p {
        margin: 10px 0 10px 0;
    }
    
    div.centered p {
        margin: 10px auto;
    }
    
    div.normal p {
        margin-bottom: 5px;
    }
    

    The uncompressed code would produce a centered paragraph with a 10px top margin and a 5px bottom margin.

    If you run the CSS styles through the CSS Compressor, you’ll get the following code, which maintains the order and cascade of the original uncompressed styles.

    div.normal p{margin:10px 0}div.centered p{margin:10px auto}div.normal p{margin-bottom:5px}
    

    Let’s say you want to aggressively compress the styles further, by combining the margins of the two div.normal p definitions. They both have the exact same selector, and they appear to redundantly style the bottom margin.

    There would be two ways to combine the margins: you can either combine the two margin definitions into the first (top) div.normal p style or combine them into the last (bottom) one. Let’s try both ways.

    If you combine the margins into the first (top) div.normal p style, you get this:

    div.normal p{margin:10px 0 5px}div.centered p{margin:10px auto}
    

    The result of combining the margins that way would result in the bottom margin being incorrectly set to 10px, because the “centered” class would override the bottom margin (because the “centered” style defintion now appears later in the cascade).

    If you combine the margins into the last (bottom) div.normal p style, you get this:

    div.centered p{margin:10px auto}div.normal p{margin:10px 0 5px}
    

    The result of combining the margins that way would result in the paragraph no longer appearing as centered, because the bottom “p” definition would override the left and right margins of “auto” that are defined in the “centered” class.

    So we can see that by combining style definitions that even have the exact same selector can cause some pretty bad problems.

    Would you personally ever write code like this? Maybe or maybe not. Because of the various “weight” rules of the cascade, it is possible to fall into this type of code trap without ever realizing it.

    Furthermore, given the fact that in today’s Web pages, multiple CSS files are often combined into one file to hit the server with fewer downloads, it is easy to imagine the CSS Compressor royally screwing up the cascade by re-writing multiple style sheets (possibly written by different people) that are appended together into one file.

    In fact, I wrote the CSS Compressor for this very scenario on my Web site, Lottery Post. Each Web page has many style sheets supporting various jQuery and other components, and the CSS Compressor is used to automatically compress all of those style sheets into one single download. All pages on the site have at least 10 different style sheets combined together, and most pages have more than that.

    For example, if you look at the code behind the CSS Compressor page itself, you will find the main style sheet in the head that looks like this:

    <link rel="stylesheet" href="http://lp.vg/css/d11019.0/j2HKnp0oKDOVoos8SA3Bpy3UHd7cAuftiXRBTKCt95r9plCnvTtBMU2BY2PoOQDEUlKCgDn83h16Tv4jbcCeZ(gupKbOQ9ko(TcspLAluwgBqrAjEhOyXvkhqHA(h5WFDypZDK2TIr(xEXVZtX7UANdFp6n1xfnxqIMR8awqGE)vrwUgY2hrCGNNTt1xV7R1LtCSfF46qdH1YQr2iA38r1SQjAgHze(9" />
    

    The gobbledeegook in the URL is actually an encrypted string containing all the style sheets to combine on the server. The server compresses them and caches the result.

    The space- and time-saving techniques on that one style sheet call include:

    • Combining many style sheets into one file/download by simply appending them all together
    • Compressing the combined style sheet using the CSS Compressor (without messing up the cascade!)
    • Using a different domain name (lp.vg) for the style sheet download, which improves the browser’s ability to download in parallel
    • Using a very short domain name (lp.vg)
    • GZip compression is applied to the style sheet on the Web server
    • The version number of the style sheet is embedded into the URL (“…/d11019.0/…”) so that if any style is changed in any of the multiple style sheets, I can change the version number and the browser will never use the version it has cached. (Note that the version number should be part of the URL path, not in the query string, because some proxy servers do not look at the query string to determine if a page should be retrieved from cache.)

    I hope this better explains things and is helpful to those looking to improve page performance!

    -Todd

    MORE INFO:

    To add to the above, imagine if we take your color example, and combine style definitions with the same selectors.

    Here are some uncompressed styles:

    div.normal p {
        margin: 10px 0 10px 0;
    }
    
    div.centered p {
        margin: 10px auto;
        color: blue;
    }
    
    div.normal p {
        color: black;
    }
    

    The CSS Compressor produces the following output:

    div.normal p{margin:10px 0}div.centered p{margin:10px auto;color:blue}div.normal p{color:#000}
    

    If we were to apply aggressive combining of style definitions that have the same selector, we will get the following code.

    Method 1, combining both into the first definition, would incorrectly make the text color blue:

    div.normal p{margin:10px 0;color:#000}div.centered p{margin:10px auto;color:blue}
    

    Method 2, combining both into the second definition, would incorrectly make the text left-aligned:

    div.centered p{margin:10px auto;color:blue}div.normal p{margin:10px 0;color:#000}
    

    The only time combining style definitions with the same selector is 100% error-free is when the definitions appear directly one after the other, but in every other case this technique risks corrupting the cascade of styles.

    I couldn’t imagine a case where any developer would write code in this manner (two style definitions with the exact same selector, one immediately after the other), so I concluded that the amount of effort required to code it, and the possibility of an additional point of failure in the compressor, was not worth it by a long-shot.

    Frankly, I would be very concerned about a CSS compressor that combined styles from different definition blocks, because the cascade is a very fragile thing, and it is extremely easy to break the cascade.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this amazing resource http://gtmetrix.com/ that you supply a URL to a website
I found this sliding panel script I like at http://www.webdesignerwall.com/demo/jquery/ , (#1 Sample Slide
i found this nice jquery plugin http://www.goat1000.com/tagcanvas.php the description says: The canvas is a
I found this article: http://www.deluxeblogtips.com/2010/05/editor-style-wordpress-30.html I created a child theme using the Twentyten theme
I found this link http://artis.imag.fr/~Xavier.Decoret/resources/glsl-mode/ , but there isn't a lot of description around
I found this Page and after resizing windowwidth, it totally changed its css-values. I
I found this great jquery bubble script online - http://jqueryfordesigners.com/coda-popup-bubbles/ - and I want
When I define this CSS in HTML I found that they not show me
I found this awesome class that converts CSS style blocks to inline. However, I
I found this great website with different layout examples at http://matthewjamestaylor.com And in particular

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.