:hover {
    /* ... */
}
<button>Hover over me!</button>
button {
    color: white;
    padding: 0.8em 1.5em;
    border: none;
    border-radius: 5px;
    background-color: orange;
}

/* Change the background color only while hovering over the button */
button:hover {
    background-color: red;
}
Rendered Output
<button>Hover over the button, then press it!</button>
button {
    color: white;
    padding: 0.8em 1.5em;
    background-color: orange;
    border: none;
    border-radius: 5px;
}

/* Note: This declaration has no effect because button:hover overrides the background color. */
button:active {
    background-color: black;
}

/* button:hover overrides the background color set by button:active. */
button:hover {
    background-color: red;
}
Rendered Output
button {
    color: white;
    padding: 0.8em 1.5em;
    background-color: orange;
    border: none;
    border-radius: 5px;
}
button:hover {
    background-color: red;
}
button:active {
    background-color: black;
}
Rendered Output
<label for="user-id">User ID</label>
<input type="text" id="user-id">
input:hover {
    background-color: red;
}
Rendered Output Hover over the "User ID" text!