`:hover` CSS pseudo-class
The :hover CSS pseudo-class matches an element when a user interacts with it using a pointing device. The pseudo-class is generally triggered when the user moves the cursor (mouse pointer) over an element without pressing the mouse button.
The **`:hover`** [CSS](/docs/Web/CSS) [pseudo-class](/docs/Web/CSS/Reference/Selectors/Pseudo-classes) matches an element when a user interacts with it using a pointing device. The pseudo-class is generally triggered when the user moves the cursor (mouse pointer) over an element without pressing the mouse button.
tabbed-shorter
```css interactive-example
.joinBtn {
width: 10em;
height: 5ex;
background-color: gold;
border: 2px solid firebrick;
border-radius: 10px;
font-weight: bold;
color: black;
cursor: pointer;
}
.joinBtn:hover {
background-color: bisque;
}
```
```html interactive-example
<p>Would you like to join our quest?</p>
<button class="joinBtn">Confirm</button>
```
Styles defined by the `:hover` pseudo-class will be overridden by any subsequent link-related pseudo-class (:link, :visited, or :active) that has at least equal specificity. To style links appropriately, put the `:hover` rule after the `:link` and `:visited` rules but before the `:active` one, as defined by the _LVHA-order_: `:link` — `:visited` — `:hover` — `:active`.
> [!NOTE]
> The `:hover` pseudo-class is problematic on touchscreens. Depending on the browser, the `:hover` pseudo-class might never match, match only for a moment after touching an element, or continue to match even after the user has stopped touching and until the user touches another element. Web developers should make sure that content is accessible on devices with limited or non-existent hovering capabilities.
## Syntax
```css
:hover {
/* ... */
}
```
## Examples
### Basic example
#### HTML
```html
<a href="#">Try hovering over this link.</a>
```
#### CSS
```css
a {
background-color: powderblue;
transition: background-color 0.5s;
}
a:hover {
background-color: gold;
}
```
#### Result
Basic_example
## Specifications
## Browser compatibility
## See also
- [Chromium bug #370155: Don't make `:hover` sticky on tap on sites that set a mobile viewport](https://crbug.com/370155)
- [Chromium bug #306581: Immediately show hover and active states on touch when page isn't scrollable.](https://crbug.com/306581)
Cite this
"`:hover` CSS pseudo-class". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:hover JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy