:hover {
    /* ... */
}
<button>마우스 커서를 올려보세요!</button>
button {
    color: white;
    padding: 0.8em 1.5em;
    border: none;
    border-radius: 5px;
    background-color: orange;
}

/* 버튼에 마우스 커서를 올려 놓았을 때에만 배경색을 변경 */
button:hover {
    background-color: red;
}
브라우저에서 실제 표시된 모습
<button>마우스 커서를 올린 후 눌러보세요!</button>
button {
    color: white;
    padding: 0.8em 1.5em;
    background-color: orange;
    border: none;
    border-radius: 5px;
}

/* button:hover가 배경색 설정을 덮어쓰기를 하기 때문에 적용되지 않음 주의! */
button:active {
    background-color: black;
}

/* button:hover가 button:active로 설정한 배경색을 덮어쓰기 함 */
button:hover {
    background-color: red;
}
브라우저에서 실제 표시된 모습
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;
}
브라우저에서 실제 표시된 모습
<label for="user-id">아이디</label>
<input type="text" id="user-id">
input:hover {
    background-color: red;
}
브라우저에서 실제 표시된 모습 '아이디'라는 텍스트에 마우스 커서를 올려 보세요!