If you are a beginner to web developer, CSS is a headache for beginners, based on my experience. It takes time to learn it and master it. This article covers some of the common errors you may encounter when writing CSS code.
1. Use px values when not required
Did you know that you don’t need to use px when you want to set the value to 0.
2. Repeat the same code
Always keep the DRY rules in mind. Don’t repeat. The number of lines of code will cost you in terms of application performance and load times.
3. Use color names
Using color codes is better.
4. Don’t use the shorthand attribute
Avoid multiple lines of code as you can do the same thing with one line.
5. No backup fonts
Loading custom web fonts for the first time incurs a performance penalty on a website. As web developers and designers, we always strive to create beautiful and good performing websites. However, often two targets will cause conflict. The displayed font CSS properties allow for a better balance between the aesthetics and performance of a website.
If you specify a value for the font-display property as fallback, the browser will wait less than a second for your custom web fonts to download. If the custom font is not available at this time, a fallback (the value of the font-display property) will be used for the lifecycle of the web page. This would be fine for users, as they won’t have to look at the “blank” text in time.Reference: cmsinstallation