better naming methods in CSS
How to name CSS classes Naming things is the hardest thing in computer science, but, in CSS, you're naming things all day long... Based on my favorite articles on the topic, and recent work experience, here are my 2 cents about how to properly name CSS classes. 0. Before to think about class name, give a good name to HTML elements If it’s an input, use the input element. It will be far easier for the reader to scan the HTML document. Example : <div class= 'submit' /> <!-- Wooot ? --> <input class= 'submit' /> <!-- Ah, ok --> Source : Raphael Goetter (french article) 1. Put the class name at the lowest possible level It impact how classes will be named. Always use the class name directly on the HTML element you want to style, even if seems to cost an extra effort. Check the article of Chris Coyer below if it is not clear why. Example : <main class= 'mainly' > <p> Lorem ipsum ...