Answer the question
In order to leave comments, you need to log in
Are there such code optimizers?
Hello. I had such a situation. I have 2 colors for text on my site. Half of the words are in black, the other half are in pink. And in order not to write in color:#f68 styles every time, I created a class called f68 and, if necessary, use it, I already prescribe the class in the span or div itself: span class="f68" Header /span . Now I found out that the phrase "text-align:center" is often found in my code, but it was possible at the very beginning to create the class "tac" and shorten the code ...
Is there such a code optimizer that, in the case of frequent repetition of one and the same style, create a class with this style and write it to the tag?
Answer the question
In order to leave comments, you need to log in
Using classes like f68 is a bad habit for a lot of reasons. One of them is that the name of the class does not reflect its essence. Instead, you can add classes that define the appearance or state of the element, such as: button-red, button-warning, align-left, and so on.
If you need to reduce the amount of scribbling when laying out, I recommend using preprocessors . This will greatly reduce the amount of code with variables and mixins.
Concerning the optimizer. I don't think there is anything like that.
The question is not about saving kilobytes, lines or letters, the question is about usability and semantics, read why css appeared at all, because you can put everything into tags. There are no such softins yet, Word, I can be wrong, in our time ... xs what people have written already.
Such things are usually decided by competent developers at the project stage. In your case, search by string with replacement is a normal solution. 4 styles replace - 5 minutes of work.
Now I've found that I often see the phrase "text-align:center" in my code.
and use a variable in the preprocessor in the case of color, no?
And your idea with classes for css properties is complete bullshit!
Forget about it forever and delete the question from here.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question