Submitted about 2 years agoA solution to the NFT preview card component challenge
NFT preview card component challenge - Solution using CSS Grid
animation
@Leo-Code-CA

Solution retrospective
Hi guys!
I have a question about best practices. I know it's usually recommended to use a CSS class selector .myclass instead of an id selector #myelement or an element selector div.
However, I was wondering, is it better to create a class even if we won't reuse it? For example:
<body>
<section>
<p class="myparagraph"></p>
</section>
<section></section>
<section></section>
<section></section>
</body>
If I want to style the paragraph, is it best practice to delete its class in the html and do:
p {
color: blue;
}
OR this:
section p {
color: blue;
}
OR do I keep the class of the paragraph (even if it won't be reused) and do:
.myparagraph {
color: blue;
}
Thanks and happy coding :)
Code
Loading...
Please log in to post a comment
Log in with GitHubCommunity feedback
No feedback yet. Be the first to give feedback on Leo-Code-CA's solution.
Join our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord