DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

CSS Button Hover Effects: Copyable Examples That Work for Keyboard and Touch

Add clear hover feedback to buttons without hiding focus feedback or making the action depend on a mouse.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use :hover to add visual feedback when a pointer is over a button, but keep the action available without hover. The examples below add color, lift, outline, and glow effects while preserving a visible keyboard-focus state and respecting reduced-motion preferences.

A safe starting point

Use a native <button> for an action. It already supports mouse, keyboard, touch, voice commands, and assistive technology; styling a decorative element to imitate a button does not provide those semantics. Set the button type deliberately: type="button" for an action that should not submit a form, or the appropriate submit/reset type when that is its job. See the MDN button reference.

<button class="button" type="button">Save changes</button>
.button {
  border: 0;
  border-radius: 0.4rem;
  padding: 0.7rem 1rem;
  color: white;
  background: #3157c8;
  transition: background-color 160ms ease, transform 160ms ease;
}

.button:hover {
  background: #2444a8;
}

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

.button:active {
  transform: translateY(1px);
}

@media (prefers-reduced-motion: reduce) {
  .button {
    transition: none;
  }
}

This is a starting point, not a guarantee that the colors contrast sufficiently in every design. Check the actual text/background contrast and ensure the focus outline is visible against the surrounding surface. Keep the hover rule an enhancement: the button’s label and operation must not depend on it.

Copyable hover effect variations

Append one of these rules to the base styles, or adapt its values. Keep a separate focus indicator even if the hover treatment is visually strong.

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

Color change

.button:hover {
  background: #2444a8;
}

A simple background or border change is usually the clearest treatment. Confirm that the label remains legible in both states.

Lift and press

.button {
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgb(0 0 0 / 18%);
}

.button:active {
  transform: translateY(0);
  box-shadow: 0 2px 5px rgb(0 0 0 / 18%);
}

The hover state suggests the control can be used; the active state gives feedback while it is being activated. Keep movement restrained and disable the transition for users requesting reduced motion, as in the base example.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Border or outline emphasis

.button {
  border: 2px solid transparent;
  transition: border-color 160ms ease;
}

.button:hover {
  border-color: #b8c9ff;
}

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

Do not make the keyboard focus treatment indistinguishable from the pointer-hover treatment. The W3C’s Technique C15 illustrates highlighting focus or hover as a way to communicate interactivity. It is an example technique, not a required coding recipe.

Glow without relying on movement

.button {
  transition: box-shadow 160ms ease, background-color 160ms ease;
}

.button:hover {
  background: #2444a8;
  box-shadow: 0 0 0 4px rgb(49 87 200 / 25%);
}

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

Use the glow as decoration alongside a legible state change, not as the only cue. Make sure it remains visible against the page background and does not obscure nearby content.

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

Make hover usable beyond a mouse

Keep the operation available on touch

:hover represents a pointer state. Touch devices do not necessarily have a sustained hover state, and browser behavior can vary. Do not reveal the only copy of the button label, an essential instruction, or the way to perform an action only on hover. MDN documents the touch caveat in its reference for :hover.

Show keyboard focus

Keep a visible focus indicator for people navigating by keyboard. :focus-visible lets the browser apply focus presentation according to its user-agent heuristics; do not remove the browser’s focus indicator unless you provide a visible replacement. The W3C notes that its techniques are examples of ways to meet WCAG, not the only valid implementation.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Respect reduced-motion preferences

If a hover or focus treatment animates, use @media (prefers-reduced-motion: reduce) to remove or reduce that motion. The W3C provides a reduced-motion example that disables hover and focus motion for this preference.

Treat revealed content differently from decoration

A color change or shadow is ordinary visual feedback. If hover or focus exposes extra content—such as a tooltip or a menu—additional requirements apply: the content should be hoverable, dismissible, and persistent where applicable. Consult the W3C guidance on content on hover or focus and Technique SCR39. Do not use a fleeting hover animation as the sole way to access meaningful information.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Links and state ordering

For links, state rules can override one another through the cascade. MDN documents the LVHA order: :link, :visited, :hover, then :active. Keep that order in mind when styling link states so later rules do not unexpectedly override earlier ones. Buttons are not links; use the appropriate element and selectors for the control’s job.

Check the effect before shipping

  • With a keyboard, tab to the button and verify that focus is obvious; activate it with the keyboard.
  • With a touch device, verify the action and its label are available without hovering.
  • Check text contrast in default and hover states, and confirm the focus outline is distinguishable from both.
  • Enable the operating system’s reduced-motion preference and confirm that hover and focus movement is removed or reduced.
  • If the interaction reveals content, verify that it can be reached by pointer and keyboard, stays available long enough to use, and can be dismissed as applicable.

Or skip the browser setup

If you need screenshots to check how a page renders, ScreenshotNeo is a website screenshot API and MCP server. One GET request returns an image or PDF. For example, using the target page URL in place of the sample:

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 documentation for request options. It accepts cookie and consent banners and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo.

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.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.