@xCordeva
Posted
Hey Leo,
As you mentioned, it's generally better to use classes instead of IDs because they are reusable.
And for your question, I wouldn't recommend using the first approach:
p { color: blue; }
This would apply to all the paragraphs on the page, which might not be what you want.
The second approach:
section p { color: blue; }
is better and can work fine for smaller projects. However, in larger projects, it can be harder to manage and understand which p
you are styling since a section could contain more than one p
That's why it's always better to use a class, even if you are not going to reuse it. Giving a class is a cleaner and more efficient way to apply styles, especially when dealing with bigger and more complex layouts where you want to be specific about which element that you're targeting.
Hope this helps
Marked as helpful
@Leo-Code-CA
Posted
Hey @xCordeva !
Thank you so much for your detailed answer! It's really helpful.
Have a great day :)