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

  • Home
  • SEARCH
  • 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 1105177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:35:27+00:00 2026-05-17T01:35:27+00:00

After working on several large web applications, and seeing gigantic style sheets with no

  • 0

After working on several large web applications, and seeing gigantic style sheets with no clear structure, I’d really love to know if people have found ways to keep their css clean for large and complicated web apps.

How do you move from a legacy, mess of css to cleaned up, nicely cascading, DRY stylesheets?

The app I’m currently working on has 12000 lines of css. It’s grown to this size organically as early on there were no standards or review of the css, the only rule was to make the app match the design. Some of the problems we constantly have:

  • Conflicting styles: one developer adds a .header { font-weight: bold;} but .header was already used in other modules and shouldn’t be bold in those.

  • Cascading problems: Foo widget has a .header but it also contains a list of Bar widgets with .header classes.

    • If we define .foo .header { … } and .bar .header { … } anything not explicitly overwritten in foo will show up in bar.
    • If we define .foo > .header and .bar > .header but later need to modify foo to wrap header in a div, our styles break.
  • Inheritance problems, we constantly redefine widget fonts to 11px/normal because some top container uses a 12px / 18 px line height.

  • Fighting against widget libraries, using libraries such as dojo/dijit or jquery ui that add tons of styles to be functional means that our code is littered with places where we have to override the library styles to get things looking just right. There are ~2000 lines of css just for tweaking the builtin dijit styles


We’re at a point where we’re thinking of implementing the following rules:

Namespace all new widget classes – if you have a widget foo all sub-classnames will be .foo_ so we get: .foo, .foo_header, .foo_content, .foo_footer. This makes our css essentially FLAT, but we see no other way to organize our code going forward without running into the legacy styles or the cascading problems I mentioned above.

Police generic styles – have a small handful of generic classes that are only to be applied in very specific situations. e.g. .editable – apply to portions of a sentence that should invoke an editor – should only contain text nodes.

Leverage css compiler mixins To avoid repeatedly defining the same styles in different widgets, define and use mixins. Although we worry the mixins will get out of control too.

How else can we move from css mess that constantly introduces regressions to something maintainable going forward.

  • 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-17T01:35:28+00:00Added an answer on May 17, 2026 at 1:35 am

    We’re using a style guide in the form of a simple HTML page with examples of every CSS rule in the stylesheet. It’s very easy to tell if you add a new, incompatible rule since the examples are aligned on top of eachother.

    An example I like: http://getbootstrap.com/components/ (added 2015)

    The other pro you get from this method is reusability: you know what you got and you know that you want the style guide to be as small as possible – therefore: reuse.

    When you make changes to styles already in use: check the style guide. If it doesn’t change it’s probably good (you might need to browse around a bit if you’ve just changed something including box model-issues, or width, height, padding, margin in general).

    How do you move from a legacy, mess of
    css to cleaned up, nicely cascading,
    DRY stylesheets?

    Use the style guide as a unit test. Once you got the essential parts in it: reduce, refactor and combine (you most probably will find some collissions between .campaign_1 span and your regular rules, inheritance can be your friend).

    Conflicting styles: one developer adds
    a .header { font-weight: bold;} but
    .header was already used in other
    modules and shouldn’t be bold in
    those.

    In reply to Adriano Varoli Piazza’s comment and the quote above: I don’t recall this as a problem fully belonging to the CSS but more to the HTML markup. No matter what you do, it will be some heavy lifting. Decide which rule you’d want to keep and take actions towards cleaning out the lesser-used-ones; for example: via inheritance: #news a .header { ... } or renaming the HTML-class a .stand_out_header { ... }.

    About the following idea

    Namespace all new widget classes – if
    you have a widget foo all
    sub-classnames will be .foo_ so we
    get: .foo, .foo_header, .foo_content,
    .foo_footer. This makes our css
    essentially FLAT, but we see no other
    way to organize our code going forward
    without running into the legacy styles
    or the cascading problems I mentioned
    above.

    Use a containing element instead, which will be much more easy to maintain:

    <div id="widget_email">
      <h2>One type of h2</h2>
    </div>
    <div id="widget_twitter">
      <h2>Another h2</h2>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got several questions regarding this issue 1) ActiveMQ after installed and started also
I've been struggling to get my mind around classes. Even after reading several websites
I'm a first year computer science student, having returned several years after finishing high
I'm trying to get my Django based webapp into a working deployment configuration, and
I am afraid that several terminologies in my question are wrong. Please bear with
I'm working with an embedded RTOS (CMX), but I think this applies to any
I am using jquery ui in several places to create ui elements like tabs,
I have several jQuery-ui range sliders on a page which add and remove rows
Integrating SimpleModal with ASP.NET I want to thank Eric for producing SimpleModal and compliment

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.