Rohan.dev๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป ๐Ÿ‡ฎ๐Ÿ‡ณ
Rohan.dev๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป ๐Ÿ‡ฎ๐Ÿ‡ณ

@rohan_webdev

11 Tweets 5 reads Mar 09, 2023
Best Practices for Writing Better CSS ๐Ÿ’ฏโšก๏ธ
A thread ๐Ÿงต
1๏ธโƒฃ Use meaningful class and ID names:
๐Ÿ‘‰ Use descriptive and meaningful names for your classes and IDs that reflect their purpose or function.
๐Ÿ‘‰ This makes your code more readable and easier to understand.
2๏ธโƒฃ Use a consistent naming convention:
๐Ÿ‘‰ Use a consistent naming convention for your classes and IDs to avoid confusion.
๐Ÿ‘‰ Some popular naming conventions include BEM (Block Element Modifier) and SMACSS (Scalable and Modular Architecture for CSS).
3๏ธโƒฃ Avoid using global styles:
๐Ÿ‘‰ Try to avoid using global styles that affect the entire document.
๐Ÿ‘‰ Instead, use specific classes or IDs to target specific elements.
4๏ธโƒฃ Use shorthand properties:
๐Ÿ‘‰ Use shorthand properties wherever possible to keep your code concise and easier to read.
๐Ÿ‘‰ For example, instead of writing separate properties for font-size, font-weight, and font-family, you can use the font property.
5๏ธโƒฃ Group related properties:
๐Ÿ‘‰ Group related properties together to make your code more organized and easier to scan.
๐Ÿ‘‰ For example, group all the font-related properties together, followed by the color-related properties.
6๏ธโƒฃ Use comments to explain your code:
๐Ÿ‘‰ Use comments to explain your code and provide context for other developers who may work on the code in the future.
7๏ธโƒฃ Use CSS preprocessors:
๐Ÿ‘‰ CSS preprocessors like Sass and Less allow you to write CSS in a more efficient and organized way, with features like variables, nesting, and mixins.
8๏ธโƒฃ Minimize your code:
๐Ÿ‘‰ Minimize your CSS code by removing unnecessary selectors, properties, and comments.
๐Ÿ‘‰ This reduces the file size and improves page load times.
By following these best practices, you can write clean, organized, and maintainable CSS code that is easy to read and understand.
Hope you found it helpful. ๐Ÿ˜Š๐Ÿ™Œ
Thats a wrap.
If you found this thread useful, please leave a like.โค๏ธ
I tweet on :
๐ŸŒ WebDev Tips/Tricks
๐Ÿ’Ÿ React
๐Ÿ“ˆ Personal Growth - Quotes n Visualisation
Follow @rohan_webdev for more such content.
Happy learning!๐Ÿ™‚

Loading suggestions...