@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