Does CSS have the concept of inheritance? How to make the newly added classA have the same style as the existing classB without using JS?

current status: I am now a project, there are 1k websites, these sites are just different styles, each site has its own personalized css style, for example, the color of the button of different sites is different.

requirements: all websites now add a "form A", and the color of "form A" needs to be the same as that of button.

Note 1: because there are too many sites, it is not possible to modify the css style files for all sites one by one. And sass less is not currently used.

Note 2: cannot be implemented in JavaScript jQuery.

I would like to ask you, is there any way to achieve it? Preferably pure CSS style

I think my question is not clear, let me redescribe the problem: at present, each website loads the basic theme.css file, and each site has its own personalized css file, and the color of button in each personalized css file is different. The problem with
is that now the page needs to add a form, and the color of the form needs to be the same as the button color in the personalized css file. In other words, the color of the form varies from site to site.
but because there are thousands of websites, it is not possible to add this attribute to each css file. So I want to know how to implement this business in the basic theme.css file.

Sep.23,2021

isn't this always there

< H2 > 1. Css variables < / H2 >
:root {
  --bgcolor: black;
}
body {
  background: var(--bgcolor);
}
< H2 > 2. Extract < / H2 >

just like the BEM naming convention, you can just pull out the public css package, and then default , success


is very simple. Take advantage of css's coverage feature
each website is added to load the default theme file: < link rel= "stylesheet" href= "theme.css" >
the following is the assumption of theme.css content

.button{
background:white
}

then load their respective theme files: < link rel= "stylesheet" href= "theme-blue.css" >

.button{
background:blue
}

overrides
as for how to load it also takes into account your engineering, project framework, etc., with different tool implementations, but that's probably how it works.
there are still some unclear requirements for you, and it is difficult to describe clearly here, so you can communicate again.

Menu