v4.0 :hover not working on edge
What version of Tailwind CSS are you using?
4.0 and 4.0.1
What build tool (or framework if it abstracts the build tool) are you using?
postcss-cli 8.5.1
What version of Node.js are you using?
Node 23:alpine
What browser are you using?
Edge
What operating system are you using?
Windows
Describe your issue
I'm fancing problems while using :hover property on Edge browser. Seems that Firefox and Chrome works. The issue can be checked at official website inside "Docs" section -> "Hover, focus, and other states"
Hey!
In Tailwind CSS v4, we use @media (hover: hover) to check if hover is available (which improves the UX on mobile devices to prevent sticky headers).
According to MDN / Can I use, this feature should work on Edge. When testing this myself in browserstack it works as expected (Windows 11, Edge 132).
https://github.com/user-attachments/assets/52116a35-7490-47c7-ac1a-19066adf3eed
Can you double check that you don't have any browser extensions that could be causing issues. Also try to update to the latest Edge version.
If this is still causing issues, you can add a custom variant, that does not have this behavior:
@custom-variant hover (&:hover);
But this will re-introduce the sticky hover on mobile device so be careful with this.
Since we are just relying on CSS here, there is not a lot we can do to improve this behavior (except for introducing that custom implementation for hover.
Hope this helps!
Hi, @RobinMalfait. Could you help with a similar problem?
I've been struggling with a :hover issue in Tailwind for the last few days. The :hover effects from the Tailwind documentation don't work in all browsers. At first, I thought the issue was caused by some Chrome extensions, but the same problem occurs in Edge (without extensions), Firefox (without extensions), and even in incognito mode. None of these browsers show any effect when hovering over the button from the hover documentation section. All browsers are up to date.
I also tested this on my OnePlus with the latest Chrome, and :hover doesn’t work there either. However, it does work in Safari.
I have no idea what the cause could be. Some hover effects work (the ones I define via custom CSS), but all Tailwind hover effects refuse to apply. However, :active works. Switching states for the button via DevTools doesn’t add any hover classes or styles.
Additionally, I noticed that in my builds, hover effect classes are added but with empty styles:
Update: They're not actually empty. The problem is that @media (hover: hover) is not being applied.
.hover\:bg-date-300 {
&:hover {
@media (hover: hover) {
background-color: var(--color-date-300);
}
}
}
What can be done about this? Is this the expected behavior?
For reference, my system details:
Edition: Windows 11 Home Insider Preview
Version: Dev
OS Build: 27774.1000
Well, turns out the issue is that the browser detects a touchscreen device... as a touchscreen device. (Yeah, Captain Obvious moment here.)
Because of this, my Surface is essentially treated as a smartphone or tablet, rather than a regular computer—despite having a mouse, a keyboard, and a 40-inch monitor attached.
So far, the only workaround I’ve found is disabling Intel(R) Precise Touch Device in Device Manager. Not ideal, but at least :hover starts working properly after that.
If anyone has a better solution that doesn’t involve completely disabling touch input, I’d love to hear it!
I had the same issue where @media (hover: hover) was not being applied, and updating my browser solved the problem