DEV Community

Discussion on: IDs vs Classes: a CSS Specificity Chapter

Collapse
 
whizkevina profile image
Aina Oluwatimilehin

But When if I needed to apply the fix to the element.

Thread Thread
 
sl4rtyb4rtf4st profile image
Andrew Millar

Let's say you element is a link inside the last <li> inside an <ul> with the class 'nav'. Then you can target that element in your style sheet using .nav li:last-of-type a { ... }

You don't have to use a class to target an element.

Thread Thread
 
whizkevina profile image
Aina Oluwatimilehin

Thanks so much, for this eye-opening technique which I don't take note of.