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 9117861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:59:50+00:00 2026-06-17T04:59:50+00:00

I am building a widget that will be displayed on a client’s site. We

  • 0

I am building a widget that will be displayed on a client’s site. We cannot use an iFrame so I am forced to use an exhaustive CSS reset (https://github.com/premasagar/cleanslate) to avoid interference with their styles. To use that solution, I need to add !important to all of my styles and because there are a lot of them and I want to keep this code easy to maintain, I’m looking for a more dynamic solution.

I am able to add !important to the stylesheet via javascript but that’s not ideal for a production environment. I am using CodeKit and LESS and wondering if either of these are able to help me easily add !important to all styles when the CSS file is generated.

Mixin?
CodeKit config?

  • 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-06-17T04:59:51+00:00Added an answer on June 17, 2026 at 4:59 am

    Update: Yes, LESS Can Help

    I hate using !important except in the most extreme circumstances. Most people use it like a chainsaw when they should be using a scalpal to do the job. Nevertheless, I understand the issues facing widget developers like yourself, and your choice to use https://github.com/premasagar/cleanslate leaves you with no option.

    Marc’s answer noted a good feature of LESS, but he failed to demonstrate how that can help in this matter.

    If you wrap your entire LESS code in a namespaced mixin, then this feature does exactly what is needed. So assume your widget code looked like this (you mentioned you are already using some type of class for your widget):

    .yourWidgetClass div > p {
      prop: something;
      &:hover {
        prop: some-hover-style;
      }
    }
    
    .yourWidgetClass .someClass {
      prop: something;
    }
    

    Then you can do this (wrapping all your widget code in #makeImportant() then calling that mixin with the !important feature noted in Marc’s answer):

    #makeImportant() {
        .yourWidgetClass div > p {
          prop: something;
          &:hover {
            prop: some-hover-style;
          }
        }
    
        .yourWidgetClass .someClass {
          prop: something;
        }
    }
    
    & {
        #makeImportant() !important;
    }
    

    This produces the following CSS Output:

    .yourWidgetClass div > p {
      prop: something !important;
    }
    .yourWidgetClass div > p:hover {
      prop: some-hover-style !important;
    }
    .yourWidgetClass .someClass {
      prop: something !important;
    }
    

    For my original (accepted) answer that was way more manually intensive, see the edit history.

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

Sidebar

Related Questions

I'm building a PHP REST API that will be utilized from a JavaScript client,
I'm building a Flex widget for a private vBulletin site, and the Flex widget
I am building a small widget that I am giving to users to embed
I'm building a widget that can be embedded in other sites. The widget is
I'm building my first android app - something that will display my tweets in
I'm building a web app that many people will be using at the same
I'm building a widget library for our mobile project. The question is to use
I'm building the back end to a site which will have multiple widgets on
I am building an app that will search an array for two or more
I am building a web widget which will be very easy to integrate. Say

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.