My friend is learning CSS and HTML. Can you find ten things he can improve in his coding style?

This page summarizes the projects mentioned and recommended in the original post on /r/css

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • oocss

    Object Oriented CSS Framework

  • OOCSS - (Object-oriented CSS) 2. Use a preprocessor. They fill the lacking features of CSS and helps you write more readable, and smaller reusable pieces of CSS. Some popular preprocessors are: 1. Sass 2. Less 3. Stylus 3. Reduce redundancy. You are using font-weight: bold for the header, but you are also setting it for the div inside. CSS stands for Cascading Style Sheets because styles in CSS are cascading, meaning child elements will inherit styles from parents. 4. Avoid using strong and complex selectors. You are using an id, but a class would do just fine. Having strong selectors means you will have a harder time overriding them later on if needed. 5. Avoid using !important as much as possible. Only use it for utility and helper classes if you must, which need to override anything, such as hiding or displaying an element. 6. Don't use inline CSS, unless your inlining critical CSS. Instead, import styles using a link tag in your head element. (Critical CSS refers to above-the-fold content. Inlining it can help users see a properly rendered page more quicker) 7. Use semantic HTML. You are assigning a header class to a div, which could have been an h1/2/3/n element. This not only helps in terms of accessibility but can also help to improve your SEO score. 8. Use rem for typography. You are using em which cascades, meaning if you set the root element to have 12px, a main element with 2em will have the font size of 24px. If you put a div inside of it with 2em, it will have a font size of 48px, meaning that the size is duplicated. This makes it hard to track down values for deeply nested elements. Instead, use rem which stands for root em, and does not cascade. 9. Make sure your formatting is consistent. You use opening brackets both after a selector and on a new line. Tools like stylelint can help you enforce certain rules to keep your code more consistent, which helps to improve readability and maintainability. 10. Outsource your colors / sizes / spacings into variables. Everything that is bound to change can be in a configuration file to make things more flexible. You can either use CSS variables for this, or a preprocessor. 11. Nothing is written in stone, feel free to come up with your own set of rules that helps you create a more dev-friendly environment. But most importantly, keep things consistent.

  • performance-checklist

    📈 A comprehensive list of performance optimization techniques to improve your site's performance

  • OOCSS - (Object-oriented CSS) 2. Use a preprocessor. They fill the lacking features of CSS and helps you write more readable, and smaller reusable pieces of CSS. Some popular preprocessors are: 1. Sass 2. Less 3. Stylus 3. Reduce redundancy. You are using font-weight: bold for the header, but you are also setting it for the div inside. CSS stands for Cascading Style Sheets because styles in CSS are cascading, meaning child elements will inherit styles from parents. 4. Avoid using strong and complex selectors. You are using an id, but a class would do just fine. Having strong selectors means you will have a harder time overriding them later on if needed. 5. Avoid using !important as much as possible. Only use it for utility and helper classes if you must, which need to override anything, such as hiding or displaying an element. 6. Don't use inline CSS, unless your inlining critical CSS. Instead, import styles using a link tag in your head element. (Critical CSS refers to above-the-fold content. Inlining it can help users see a properly rendered page more quicker) 7. Use semantic HTML. You are assigning a header class to a div, which could have been an h1/2/3/n element. This not only helps in terms of accessibility but can also help to improve your SEO score. 8. Use rem for typography. You are using em which cascades, meaning if you set the root element to have 12px, a main element with 2em will have the font size of 24px. If you put a div inside of it with 2em, it will have a font size of 48px, meaning that the size is duplicated. This makes it hard to track down values for deeply nested elements. Instead, use rem which stands for root em, and does not cascade. 9. Make sure your formatting is consistent. You use opening brackets both after a selector and on a new line. Tools like stylelint can help you enforce certain rules to keep your code more consistent, which helps to improve readability and maintainability. 10. Outsource your colors / sizes / spacings into variables. Everything that is bound to change can be in a configuration file to make things more flexible. You can either use CSS variables for this, or a preprocessor. 11. Nothing is written in stone, feel free to come up with your own set of rules that helps you create a more dev-friendly environment. But most importantly, keep things consistent.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • stylus

    Expressive, robust, feature-rich CSS language built for nodejs

  • OOCSS - (Object-oriented CSS) 2. Use a preprocessor. They fill the lacking features of CSS and helps you write more readable, and smaller reusable pieces of CSS. Some popular preprocessors are: 1. Sass 2. Less 3. Stylus 3. Reduce redundancy. You are using font-weight: bold for the header, but you are also setting it for the div inside. CSS stands for Cascading Style Sheets because styles in CSS are cascading, meaning child elements will inherit styles from parents. 4. Avoid using strong and complex selectors. You are using an id, but a class would do just fine. Having strong selectors means you will have a harder time overriding them later on if needed. 5. Avoid using !important as much as possible. Only use it for utility and helper classes if you must, which need to override anything, such as hiding or displaying an element. 6. Don't use inline CSS, unless your inlining critical CSS. Instead, import styles using a link tag in your head element. (Critical CSS refers to above-the-fold content. Inlining it can help users see a properly rendered page more quicker) 7. Use semantic HTML. You are assigning a header class to a div, which could have been an h1/2/3/n element. This not only helps in terms of accessibility but can also help to improve your SEO score. 8. Use rem for typography. You are using em which cascades, meaning if you set the root element to have 12px, a main element with 2em will have the font size of 24px. If you put a div inside of it with 2em, it will have a font size of 48px, meaning that the size is duplicated. This makes it hard to track down values for deeply nested elements. Instead, use rem which stands for root em, and does not cascade. 9. Make sure your formatting is consistent. You use opening brackets both after a selector and on a new line. Tools like stylelint can help you enforce certain rules to keep your code more consistent, which helps to improve readability and maintainability. 10. Outsource your colors / sizes / spacings into variables. Everything that is bound to change can be in a configuration file to make things more flexible. You can either use CSS variables for this, or a preprocessor. 11. Nothing is written in stone, feel free to come up with your own set of rules that helps you create a more dev-friendly environment. But most importantly, keep things consistent.

  • stylelint

    A mighty CSS linter that helps you avoid errors and enforce conventions.

  • OOCSS - (Object-oriented CSS) 2. Use a preprocessor. They fill the lacking features of CSS and helps you write more readable, and smaller reusable pieces of CSS. Some popular preprocessors are: 1. Sass 2. Less 3. Stylus 3. Reduce redundancy. You are using font-weight: bold for the header, but you are also setting it for the div inside. CSS stands for Cascading Style Sheets because styles in CSS are cascading, meaning child elements will inherit styles from parents. 4. Avoid using strong and complex selectors. You are using an id, but a class would do just fine. Having strong selectors means you will have a harder time overriding them later on if needed. 5. Avoid using !important as much as possible. Only use it for utility and helper classes if you must, which need to override anything, such as hiding or displaying an element. 6. Don't use inline CSS, unless your inlining critical CSS. Instead, import styles using a link tag in your head element. (Critical CSS refers to above-the-fold content. Inlining it can help users see a properly rendered page more quicker) 7. Use semantic HTML. You are assigning a header class to a div, which could have been an h1/2/3/n element. This not only helps in terms of accessibility but can also help to improve your SEO score. 8. Use rem for typography. You are using em which cascades, meaning if you set the root element to have 12px, a main element with 2em will have the font size of 24px. If you put a div inside of it with 2em, it will have a font size of 48px, meaning that the size is duplicated. This makes it hard to track down values for deeply nested elements. Instead, use rem which stands for root em, and does not cascade. 9. Make sure your formatting is consistent. You use opening brackets both after a selector and on a new line. Tools like stylelint can help you enforce certain rules to keep your code more consistent, which helps to improve readability and maintainability. 10. Outsource your colors / sizes / spacings into variables. Everything that is bound to change can be in a configuration file to make things more flexible. You can either use CSS variables for this, or a preprocessor. 11. Nothing is written in stone, feel free to come up with your own set of rules that helps you create a more dev-friendly environment. But most importantly, keep things consistent.

  • Sass

    Sass makes CSS fun!

  • OOCSS - (Object-oriented CSS) 2. Use a preprocessor. They fill the lacking features of CSS and helps you write more readable, and smaller reusable pieces of CSS. Some popular preprocessors are: 1. Sass 2. Less 3. Stylus 3. Reduce redundancy. You are using font-weight: bold for the header, but you are also setting it for the div inside. CSS stands for Cascading Style Sheets because styles in CSS are cascading, meaning child elements will inherit styles from parents. 4. Avoid using strong and complex selectors. You are using an id, but a class would do just fine. Having strong selectors means you will have a harder time overriding them later on if needed. 5. Avoid using !important as much as possible. Only use it for utility and helper classes if you must, which need to override anything, such as hiding or displaying an element. 6. Don't use inline CSS, unless your inlining critical CSS. Instead, import styles using a link tag in your head element. (Critical CSS refers to above-the-fold content. Inlining it can help users see a properly rendered page more quicker) 7. Use semantic HTML. You are assigning a header class to a div, which could have been an h1/2/3/n element. This not only helps in terms of accessibility but can also help to improve your SEO score. 8. Use rem for typography. You are using em which cascades, meaning if you set the root element to have 12px, a main element with 2em will have the font size of 24px. If you put a div inside of it with 2em, it will have a font size of 48px, meaning that the size is duplicated. This makes it hard to track down values for deeply nested elements. Instead, use rem which stands for root em, and does not cascade. 9. Make sure your formatting is consistent. You use opening brackets both after a selector and on a new line. Tools like stylelint can help you enforce certain rules to keep your code more consistent, which helps to improve readability and maintainability. 10. Outsource your colors / sizes / spacings into variables. Everything that is bound to change can be in a configuration file to make things more flexible. You can either use CSS variables for this, or a preprocessor. 11. Nothing is written in stone, feel free to come up with your own set of rules that helps you create a more dev-friendly environment. But most importantly, keep things consistent.

  • less.js

    Less. The dynamic stylesheet language.

  • OOCSS - (Object-oriented CSS) 2. Use a preprocessor. They fill the lacking features of CSS and helps you write more readable, and smaller reusable pieces of CSS. Some popular preprocessors are: 1. Sass 2. Less 3. Stylus 3. Reduce redundancy. You are using font-weight: bold for the header, but you are also setting it for the div inside. CSS stands for Cascading Style Sheets because styles in CSS are cascading, meaning child elements will inherit styles from parents. 4. Avoid using strong and complex selectors. You are using an id, but a class would do just fine. Having strong selectors means you will have a harder time overriding them later on if needed. 5. Avoid using !important as much as possible. Only use it for utility and helper classes if you must, which need to override anything, such as hiding or displaying an element. 6. Don't use inline CSS, unless your inlining critical CSS. Instead, import styles using a link tag in your head element. (Critical CSS refers to above-the-fold content. Inlining it can help users see a properly rendered page more quicker) 7. Use semantic HTML. You are assigning a header class to a div, which could have been an h1/2/3/n element. This not only helps in terms of accessibility but can also help to improve your SEO score. 8. Use rem for typography. You are using em which cascades, meaning if you set the root element to have 12px, a main element with 2em will have the font size of 24px. If you put a div inside of it with 2em, it will have a font size of 48px, meaning that the size is duplicated. This makes it hard to track down values for deeply nested elements. Instead, use rem which stands for root em, and does not cascade. 9. Make sure your formatting is consistent. You use opening brackets both after a selector and on a new line. Tools like stylelint can help you enforce certain rules to keep your code more consistent, which helps to improve readability and maintainability. 10. Outsource your colors / sizes / spacings into variables. Everything that is bound to change can be in a configuration file to make things more flexible. You can either use CSS variables for this, or a preprocessor. 11. Nothing is written in stone, feel free to come up with your own set of rules that helps you create a more dev-friendly environment. But most importantly, keep things consistent.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts