Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 2 years ago

NFT preview card component challenge - Solution using CSS Grid

animation
Leo-Code-CA•60
@Leo-Code-CA
A solution to the NFT preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

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 GitHub

Community 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

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner
  • Use cases

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License