bdavidxyz.com
How to name CSS classes
23
Naming things is the hardest thing in computer science, but, in CSS, you're naming things all day long... Read full article
Naming things is the hardest thing in computer science, but, in CSS, you're naming things all day long... Read full article
Liam Maddison
9y agoNice article. When you said: /* Instead, assign a class name to p : */ .paragraphly { } I don’t agree with this. Adding a class to a <p> doesn’t bode well with me. The html classes above should be componentized to allow any developer to go into that <p>.
.component-block .component-block__element p
. Global variables are bad! Especially on big projects.Jon
9y agoBut there’s nothing more global than using a tag name in a css file, isn`t it? When you use a classname on that p, you have a specific style for that element. If you use .component-block__element p, you are going to specify styles on every p below that container. Maybe you are not going to use more p elements inside the container now, but maybe you will in the future, and then, refactor time comes!