0

I'm looking for a tool that helps me to identify CSS color properties (color, background-color, border-color etc.) and combined the selectors instead of repeating the color property over and over.

so a code like this:

body {color: #656565;}        
a {color: #c0c0c0;}        
h1 {color: #000;}

.norm-element {color: #656565;}    
.accent-element {color: #c0c0c0;}

would end:

body, .norm-element {
    color: #656565;
}

a, .accent-element {
    color: #c0c0c0;
}

h1 { color: #000; }
1
  • I'm not sure there's a tool that does exactly what you want, but I have had some success using clean-css to optimize and merge rules github.com/jakubpawlowicz/clean-css Commented Feb 12, 2019 at 18:24

1 Answer 1

1

You could use css variables. Resources here and browser support which is pretty good here. So from your example

body {color: #656565;}        
a {color: #c0c0c0;}        
h1 {color: #000;}
.norm-element {color: #656565;}    
.accent-element {color: #c0c0c0;}

becomes

  :root {
    --main-bg-color: #656565;
  }
  body, .norm-element {
    color: var(main-bg-color);
   }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.