Quick Tips To Write Quality Css
There are some points we need to pay attention to while writing CSS. In this post, I would like to share some of the most important ones with you. I believe these 7 tips will help you to improve the quality of your CSS code.
1. Write descriptive class names
If you do, won't have to checek back with the HTML to see what you are editing.
2. Avoid using negative values
Sooner or later , you will need a margin-left:-10px, but that's just like hiding the dirt under the carpet
3. Make your CSS Scalable
Media queries will never be a pain again if you master this useful skill.
4. Do not use !important
This command is like sudo in the internet. It will most likely overwirte CSS that you don't want to be changed.
What happens next? The !important tag has the highest specificity of all CSS selectors.
You're basically saying to the browser to apply that specific rule with the !important tag always and under any circumstances. This is not good because CSS rules can differ from one selector to another, from parent selector to child.
The only way to override an important tag is to use another important tag. And this leads to using more and more important tags. Trust me, in the near future your project code will be full of !important tags, which makes your CSS code much harder to maintain. So try not to use it.
So just why, before using it.
As a Frontend Developer with a couple of years of experience, these are the most important tips that I can suggest for improving your CSS skills.
Thank you for reading!