:hover not applying to an element with a class [duplicate]

19 hours ago 3
ARTICLE AD BOX

The selectors you're using don't mean what you think they mean.

The first set of selectors do indeed target your <a> element:

a:link { color: #458dff; }

However, these do not:

.navLink a:link { color: #458dff; }

These are looking for <a> elements which are descendants of a .navLink element. You have just the one element, no ancestors or descendants. So the selector needs to target the element itself as both an <a> and a .navLink:

a.navLink:link { color: #458dff; } a.navLink:visited { color: red; } a.navLink:hover { color: #ffa100; }

David's user avatar

3 Comments

This also does not work. My browser still only styles it using the normal a:link

2026-03-09T19:39:04.99Z+00:00

This turned out to be a simple typo in the style sheet, I'll be deleting the question since it doesn't provide any new info edit: turns out I can't delete it :p

2026-03-10T00:03:41.807Z+00:00

Read Entire Article