Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't ":focus:not(:active)" pseudo-class work?

Tags:

html

css

I'm trying to figure out if there's a way to allow for prevent the styling of the ":focus" pseudo-class from being applying when there is a ":focus:active" or click event without the use of jQuery/JS. As the ":active" state is dependent on the ":focus" state, I would presume that ":focus:not(:active)" work, but it does not. Is there any way to combine ":not" with ":focus" to prevent "focus:active" from triggering "focus"?

like image 209
litel Avatar asked Oct 27 '25 09:10

litel


2 Answers

:not(:focus) is the closest you can get in CSS

like image 110
Scott Paradis Avatar answered Oct 29 '25 22:10

Scott Paradis


You can juste use :focus-visible this selector only triggers on focus not on active.

like image 20
Joska Potin Avatar answered Oct 30 '25 00:10

Joska Potin