Naming Conventions while coding CSS

- Use lowercase and separate words with hyphens when naming selectors. Avoid camelcase and underscores. Use human readable selectors that describe what element(s) they style.

- Use human readable selectors that describe what element(s) they style.

Correct Approach:-

 

#comment-form {
margin: 0;
}

Incorrect Approach:-

 

#commentForm { /* Avoid camelcase. */
margin: 0;
}
#comment_form { /* Avoid underscores. */
margin: 0;
}
#c1-xr { /* What is a c1-xr?! Use a better name. */
margin: 0;
}

Previous Post     Next Post