I do not even know how to ask. Suppose there is a large CSS file with many identical styles (for example, color:#000 ). How can I prescribe this style only once and so that it is transmitted to all lines where there is for example color: какое-то слово or something like that. I saw on CodePen that they are doing this, but at least I don’t remember to kill and I don’t even know what words to look for
- Don't do that. This is not cross-browser and many browsers do not support CSS variables. - Yuri
- frontender.info/css-variables-why-should-you-care or habrahabr.ru/post/141920 - Yuri
- You can use SASS sass-scss.ru . - G.Denis
|
2 answers
This is done through CSS variables:
html { --color: red; } span { color: var(--color); } <span>Цвет</span> But I do not advise you to use them, since the method is not cross-browser and is not supported in older versions of browsers at all.
- oneand what is var? - user33274
- Instead of
--coloryou can write anything? - steep - @ MaksimLensky,
varis a variable - Yuri - @steep, put before the text
--need - Yuri - @Yuri yes, I understand that it is variable, but does it apply to css? - user33274
|
Use preprocessors like sass / scss or stylus . They support variables, functions, nesting and many more other buns)
|