Guideline: Remove unnecessary spaces and line breaks to save bytes and keep the code clean.
/* Instead of this */
h1 {
margin: 0;
}
/* Use this */
h1 { margin: 0 }
Guideline: We recommend using 2 spaces instead of 4 for code indentation in your CSS files as it saves bytes. By reducing indentation size, you trim unnecessary whitespace in your code.
Guideline: Omit quotes around font and font family names when they are not necessary.
/* Instead of this */
h1 {
font-family: "Arial", sans-serif
}
/* Use this */
h1 {
font-family: Arial, sans-serif
}
Guideline: Use HTML tags (<strong>
, <b>
, <em>
, <i>
) for styling text instead of relying solely on CSS properties. We recommend using just <b>
and <i>
as they’re much shorter!
/* Instead of this */
font-weight: bold
/* Instead of this */
font-style: italic
<!-- Use this -->
<b>bold</b>
<!-- Use this -->
<i>italic</i>
Guideline: Remove redundant values from properties that don’t need them.
/* Instead of this */
background: none repeat scroll 0 0 transparent
/* Use this */
background: none