Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To create a CSS hover effect, write the element’s normal style and then a second rule using the same selector with :hover, such as .button:hover. Put any transition on the normal rule so the change animates both when the pointer arrives and when it leaves. Hover should add feedback—not be the only way to find or use essential content.

How CSS hover works

:hover is a user-action pseudo-class. It matches an element while a pointing device designates it; it does not click the element or perform an action on its own. The normal rule defines the resting appearance, and the :hover rule defines the pointer-state appearance. See the MDN reference for :hover.

Smallest complete button example

<button class="button">Save changes</button>
.button {
  background: #2457d6;
  color: white;
  transition: background-color 160ms ease;
}

.button:hover {
  background: #173b98;
}

.button:focus-visible {
  outline: 3px solid #111;
  outline-offset: 3px;
}

The base rule styles the button at rest. The hover rule changes its background while the pointer is over it. The transition belongs on the base rule; that way the change is gradual in both directions. :focus-visible supplies a separate visible focus cue, typically when a person is navigating with a keyboard.

Useful hover effect examples

Change a link’s color or underline

Color and decoration changes are simple ways to reinforce that a link is interactive. Keep links recognizable before hover, and retain a clear focus style for keyboard users.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
a {
  color: #1455b8;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  transition: color 160ms ease;
}

a:hover {
  color: #8a2d13;
}

a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

Reveal a restrained underline

A pseudo-element can animate an underline without changing the link’s layout. The link remains underlined at rest through its text decoration, so the interaction is not communicated only by hover.

.nav-link {
  position: relative;
  color: #173b98;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.25em;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
}

@media (prefers-reduced-motion: no-preference) {
  .nav-link::after {
    transition: transform 160ms ease;
  }

  .nav-link:hover::after,
  .nav-link:focus-visible::after {
    transform: scaleX(1);
  }
}

Add a shadow or slight lift

For cards and buttons, a modest shadow or small transform can signal interactivity. Prefer transforms to changing dimensions or margins, which can shift nearby content and make the page jump.

.card {
  transform: none;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .card {
    transition: transform 160ms ease, box-shadow 160ms ease;
  }

  .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
  }
}

Use an image overlay carefully

An overlay can add visual emphasis to an image, but do not put the only copy of a title, description, or action inside content that appears only on hover. Touch users may not have a convenient hover state. Keep essential information visible, or provide a persistent control such as a button that works by tap and keyboard.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Get link states and transitions right

Use LVHA order for link states

When link-state selectors have equal specificity, write them in this order: :link, :visited, :hover, :active. The mnemonic is LVHA. A later rule with equal specificity can override an earlier one, so placing :hover after :active may prevent the active style from appearing as intended.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
a:link { color: #1455b8; }
a:visited { color: #6741a5; }
a:hover { color: #8a2d13; }
a:active { color: #b21f2d; }

Transition only the properties you need

Declare a transition on the normal state and list the properties that should change. Avoid a blanket transition on every property: it can animate unrelated changes and make effects harder to control.

.button {
  background-color: #2457d6;
  transform: none;
  transition: background-color 160ms ease, transform 160ms ease;
}

.button:hover {
  background-color: #173b98;
  transform: translateY(-1px);
}

Make hover effects work for touch and keyboard

Do not hide required behavior behind hover

Touchscreens may not offer convenient hover, and browser behavior after a tap varies: hover may not match, may appear briefly, or may linger. MDN describes :hover as “problematic on touchscreens.” Treat hover as an enhancement, not a required step to reveal information or operate a control. See MDN’s documentation for the hover media feature.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

You can limit a pointer-only visual enhancement to devices whose primary input can conveniently hover:

@media (hover: hover) {
  .card:hover {
    box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
  }
}

This query is a capability check for the primary input; it is not a replacement for a usable tap or keyboard interaction. If a card reveals a control or content, make that available in a persistent or explicitly activated way as well.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Provide visible keyboard focus

Hover styling does not apply when someone navigates by keyboard. Give interactive elements a visible focus treatment, for example with :focus-visible, rather than removing the browser outline without an equivalent. The MDN pseudo-classes reference covers :focus and :focus-visible; web.dev’s accessibility guidance also addresses keyboard focus and motion preferences.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Respect reduced-motion settings

For movement effects, condition the transition on the user not requesting reduced motion. A simple alternative is no transform and no animated transition:

.card {
  transform: none;
}

@media (prefers-reduced-motion: no-preference) {
  .card {
    transition: transform 160ms ease;
  }

  .card:hover {
    transform: translateY(-2px);
  }
}

Check the effect before shipping

  • Move a mouse or trackpad pointer over the element and confirm the intended state appears and clears when the pointer leaves.
  • Tab through interactive elements and confirm each has a visible focus indicator; try the interaction with the keyboard rather than relying on hover.
  • Use a touch-capable device or emulator. Essential content and actions should remain available without depending on a hover state.
  • Check the design with reduced motion enabled. Motion should be optional, not required to understand the state change.
  • Check that the effect does not resize or reposition nearby content unexpectedly.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common CSS hover problems

The hover rule has no visible effect

Confirm the selector matches the element and that the changed property produces a visible difference. If another rule wins in the cascade, compare specificity and source order; inspect the computed style in the browser’s developer tools.

A link’s active color does not appear

For equal-specificity link state rules, use LVHA order. Also check whether a more specific selector or later stylesheet rule overrides the active style.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

The effect works with a mouse but not on a phone

That can be expected: touch hover behavior varies. Do not make the effect essential. Keep information visible or provide a tap-operable control, and use @media (hover: hover) only to scope optional hover decoration.

Nearby content jumps when the pointer arrives

A hover rule that changes width, height, padding, border thickness, or margins can alter layout. Reserve space in the base state or use a shadow or transform for visual emphasis without changing surrounding layout.

The animation feels excessive

Shorten or remove the transition, animate only the properties that need it, and honor prefers-reduced-motion for movement.

Or skip the browser setup

If you need a screenshot of a page showing its hover state, first make that state reproducible: CSS hover effects normally require a pointing device to designate the element, and the screenshot request alone is not a substitute for interaction. For ordinary page captures, ScreenshotNeo is a website screenshot API and MCP server. One GET request can return an image or PDF; its supported options include custom JavaScript and CSS.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. ScreenshotNeo accepts cookie or consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server offers screenshot tools for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.