Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Static product card using grid

@Moses2308

Desktop design screenshot for the QR code component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


I was wondering what was the best approach to styling an element. The method I usually see is to give it a class, and select it in css using the class name. Is this the normal way of doing it?

I was also wondering if there were any other things I could've done better. I would like to know if there were any practices I didn't use that are recommended.

Any other tips would be greatly appreciated.

Community feedback

Jack 150

@Damuzid

Posted

Hey Moses,

I had the same question as you regarding styling elements when I started coding. I recommend to just use the class selector when styling with CSS. As stated by Bandaru you could use the id but this has some drawbacks. The same class can be used on multiple elements, but you can't do this with id's because they have to be unique.

If you use the class selector for css than when you're ready to start using JavaScript you can add the id's for use with your Javascript. This makes your code alot more flexible and will not break your Javascript when changing classes when trying new layouts etc.

Id's and classes can be used together without issues like this:

<div id="yourid" class="yourclass">

Hope this helped you! and good luck with your next challenge.

Marked as helpful

1
Hassia Issah 50,670

@Hassiai

Posted

Replace<article class="code-card">with the main tag and <div class="attribution"> with the footer tag to fix the accessibility issues. click here for more on web-accessibility and semantic html

To center .code-card on the page using grid, add min-height:100vh to the body.

To center .code-card on the page using grid:
body{
min-height: 100vh;
display: grid;
place-items: center;
}

Replace the padding in .code-card__text with margin, the value of the font-size in rem is 0.9375rem.

Hope am helpful.

Well done for completing this challenge. HAPPY CODING

Marked as helpful

0

@SindhujaBandaru

Posted

Hello Moses! Congratulations on completing another challenge.

To style an element there is another way that is using id=" some name". And access this in CSS using #. #idname{ your code here; }

Hope this helps!!!

0

Please log in to post a comment

Log in with GitHub
Discord logo

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