High-Contrast Focus

Image stays at normal contrast at rest and transitions to clearly higher contrast on hover/focus-visible.

High-Contrast Focus demo

Hover or focus the image to see the effect.

HTML

description

CSS

.hover-effect.high-contrast.focus img{
  transition: filter 0.5s ease;
}
.hover-effect.high-contrast.focus:hover img,
.hover-effect.high-contrast.focus:focus-visible img{
  filter: contrast(1.8);
}
@media (prefers-reduced-motion: reduce) {
  .hover-effect.high-contrast.focus img{
    transition: none;
  }
  .hover-effect.high-contrast.focus:hover img,
  .hover-effect.high-contrast.focus:focus-visible img{
    filter: contrast(1.8);
  }
}

The animates filter: contrast() to 1.8 on hover/focus-visible. The wrapper carries the focus class as a marker and tabindex="0" so it is keyboard-focusable. Select the code and copy with Ctrl+C or ⌘C.