CKTIS / CSS
:hover — the pointer hover pseudo-class
The :hover pseudo-class matches an element designated with a pointing device, such as a mouse pointer, without requiring a click. It lets you change appearance while pointing, but must not be the only way to access important content or functionality.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
selector:hover { property: value; }:hover is a CSS pseudo-class describing the pointer hover state. .demo:hover selects an element with class demo while the user designates it with a pointing device. It does not require a click and is distinct from :active and keyboard focus; these states can occur together.
Matching is not limited to the element directly under the pointer: it also includes its flat-tree ancestors, up to and including the first top-layer element or the root, whichever comes first. HTML additionally matches an associated control when its label matches :hover; that alone does not mean the control is directly designated.
A device may not detect hovering without activation. Therefore, do not make access to important content or interface operation depend exclusively on :hover. Provide independent keyboard operation and a visible focus indicator.
In the example, .demo:hover reverses the button colors without clicking. Moving the pointer away restores the base colors. The example is intended for manual verification in a browser with a hover-capable pointing device.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>:hover example</title>
<style>
.demo {
background-color: white;
color: black;
border: 2px solid black;
padding: 12px 20px;
}
.demo:hover {
background-color: black;
color: white;
}
</style>
<button class="demo" type="button">Hover me</button>
</html>Result
Pointer outside: white background, black text. Pointer over the button: black background, white text. Moving the pointer outside restores the initial colors.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.