What is the difference between a class and ID,I believe they will give the same effect .
Hey @marinaselim classes should generally be used for most cases, the ID selector is generally reserved for elements that require a “higher level of specificity”…
When you have a css rule with many selectors it is said to have a higher level of specificity
.hero li a span
which reads as, selecting the span within the link tags, of an li element, contained by the parent element with a class of "hero"
we could make rules 3x longer than this if we wanted to but that doesnt make it easier for us!
so the ID selector can be assigned to reduce the amount of selectors and simply give the targeted element (in this case “span”) a priority over the class namings
This topic was automatically closed after 7 days. New replies are no longer allowed.