26 ms·
I'm actually saying giving a class name to all elements that you use inside the body tag. Really good reference is the new Calypso [1] Repository which has som
by drinchev 11y ago
I'm actually saying giving a class name to all elements that you use inside the body tag.
Really good reference is the new Calypso [1] Repository which has some really nice examples [2].
To answer specifically to your example. I usually write something like this :
<h1 class="heading">Use <strong class="heading-keyword">classes</strong> instead of tag names</h1>
Semantically the css looks much better
.heading { ... }
.heading-keyword { ... }
Also keep in mind that CSS has built-in specificy, which is a game-changer and can turn your code into a nightmare. For your example I would never write ( using the same markup ) :
h1 strong { color: blue; }
strong { color: red; /* won't work */ }
because to override it i would need to include the hierarchy all the time.
1: https://github.com/Automattic/wp-calypso/ https://github.com/Automattic/wp-calypso/
2: https://github.com/Automattic/wp-calypso/blob/a7478174b0441760c332fcb4b8c454f5b8d73dfc/client/signup/step-header/index.jsx https://github.com/Automattic/wp-calypso/blob/a7478174b04417...