Question
How to Inspect :hover State in Chrome DevTools
Question
I want to inspect the :hover styles for an anchor element in Chrome DevTools. In Firebug, there is a style dropdown that lets me select different element states.
I cannot find an equivalent feature in Chrome. Am I missing something?
Short Answer
By the end of this page, you will understand how CSS pseudo-classes like :hover work and how to force them in Chrome DevTools for debugging. You will also learn when this technique is useful, how it fits into real front-end workflows, and what common mistakes to avoid when inspecting interactive states.
Concept
CSS pseudo-classes let you style elements based on a condition or state. One of the most common pseudo-classes is :hover, which applies styles when the user's pointer is over an element.
a:hover {
color: red;
}
This matters because many interactive UI elements change appearance depending on state:
- Links highlight on hover
- Buttons change color when hovered or focused
- Menus open when a parent item is hovered
- Cards show overlays or actions on hover
The challenge is that hover states can disappear as soon as you move your mouse into DevTools. To solve this, Chrome DevTools lets you force an element state such as:
:hover:active:focus:visited(limited for privacy reasons):focus-within:focus-visible
Forcing a state means DevTools temporarily treats the selected element as if it is hovered, focused, or active, even when your mouse is somewhere else.
This is important in real programming because interactive bugs often only appear in a specific state. If you cannot freeze that state, debugging becomes difficult.
Mental Model
Think of a web element like a door with different modes:
- Normal mode: the door is closed
:hover: someone is standing near it:active: someone is pushing it:focus: someone selected it with keyboard or click
DevTools gives you a control panel that can lock the door into one of those modes. That way, you can inspect the styles without needing to keep your mouse perfectly positioned.
Syntax and Examples
The core CSS syntax for :hover is:
selector:hover {
/* styles */
}
Example:
<a class="nav-link" href="#">Products</a>
.nav-link {
color: #333;
text-decoration: none;
}
.nav-link:hover {
color: #0066cc;
text-decoration: underline;
}
When the user points at the link, the browser applies the :hover rule.
How to inspect it in Chrome DevTools
- Open DevTools.
- Inspect the element.
- In the Elements panel, select the element.
- Open the Styles pane.
- Click
:hovor the state toggle control. - Check
:hover.
Step by Step Execution
Consider this example:
<a class="profile-link" href="#">View profile</a>
.profile-link {
color: black;
}
.profile-link:hover {
color: green;
font-weight: bold;
}
Here is what happens step by step:
- The page loads.
- The browser sees the
.profile-linkrule and gives the linkcolor: black. - The browser also reads
.profile-link:hover, but it does not apply it yet. - When the pointer moves over the link, the browser checks whether the
:hovercondition is true. - Since it is true, the browser applies the hover rule.
- The link becomes green and bold.
- If you move your mouse away, the
:hovercondition becomes false and the browser removes those styles.
Now in Chrome DevTools:
- Select the
<a>element in the Elements panel. - Click the pseudo-state toggle such as .
Real World Use Cases
Developers commonly inspect :hover states in situations like these:
- Navigation menus: checking hover colors, underline effects, or dropdown visibility
- Buttons: verifying hover feedback for primary and secondary actions
- Cards and product tiles: showing overlay buttons or extra details on hover
- Tables and lists: highlighting rows when the user points at them
- Charts and dashboards: inspecting hover tooltips and emphasis styles
- Design systems: validating that components follow the same hover behavior across the app
Example: an e-commerce site may use hover to reveal an Add to cart button on product cards. If the button appears in the wrong place, forcing :hover in DevTools makes it much easier to debug.
Real Codebase Usage
In real projects, developers use forced element states as part of a larger debugging workflow.
Common patterns include:
- Checking state-specific CSS rules: verify whether a
:hoverselector is matching the expected element - Inspecting specificity issues: see whether another rule overrides the hover style
- Debugging nested selectors: for example,
.card:hover .actions { opacity: 1; } - Testing accessibility states alongside hover: compare
:hoverwith:focusand:focus-visible - Reviewing transitions: inspect the final state after a hover animation starts
- Validating component libraries: confirm that shared button or link components behave correctly in every state
A common real-codebase pattern is a parent hover controlling a child:
.card .actions {
opacity: 0;
}
.card:hover .actions {
opacity: 1;
}
When debugging this, developers often force :hover on .card, not on .actions, because the parent element controls the state.
Common Mistakes
Here are common mistakes beginners make when debugging :hover.
1. Inspecting the wrong element
Sometimes the hover rule is on a parent element, not the visible child.
Broken assumption:
.menu-item:hover .submenu {
display: block;
}
If you force :hover on .submenu, nothing happens. You need to force it on .menu-item.
2. Expecting hover on touch devices
Some touch devices do not behave like desktop hover interactions. A hover effect may be inconsistent or absent.
Avoid relying only on :hover for important functionality.
3. Forgetting CSS specificity
A hover rule may exist but still lose to a more specific selector.
Example:
a:hover {
color: red;
}
.nav a {
color: blue;
}
Depending on the full stylesheet, your hover rule may not win. Check the Styles pane to see which rule is applied or crossed out.
Comparisons
Here is a comparison of common interactive pseudo-classes:
| Pseudo-class | When it applies | Common use |
|---|---|---|
:hover | Pointer is over the element | Link and button hover styles |
:active | Element is being pressed | Pressed button feedback |
:focus | Element has focus | Forms, keyboard navigation |
:focus-visible | Focus is visible and should be shown | Accessible keyboard focus rings |
:visited | Link has been visited | Styling visited links with privacy limits |
:hover vs :focus
Cheat Sheet
selector:hover {
/* hover styles */
}
Quick rules:
:hoverapplies when the pointer is over an element- Use Chrome DevTools Elements > Styles > :hov to force
:hover - Inspect the correct element; hover may be defined on a parent
- Check crossed-out CSS rules for specificity conflicts
- Compare hover with
:focusfor accessibility - Do not rely on hover alone for critical actions on touch devices
Common patterns:
.button:hover {
background: blue;
}
.card:hover .actions {
opacity: 1;
}
nav a:hover {
text-decoration: underline;
}
Useful DevTools workflow:
- Inspect element
- Select node in Elements panel
- Click
:hov - Enable
:hover - Check Styles and Computed tabs
Edge cases:
FAQ
How do I force :hover in Chrome DevTools?
Open DevTools, inspect the element, go to the Elements panel, and use the :hov control in the Styles pane to enable :hover.
Why does my hover style disappear when I inspect the element?
Moving the mouse into DevTools usually removes the real hover state. Forcing :hover keeps it active while you inspect the CSS.
Can I inspect :active and :focus too?
Yes. Chrome DevTools lets you force several pseudo-class states, including :hover, :active, :focus, and others.
Why is my :hover CSS not applying?
Possible reasons include selecting the wrong element, CSS specificity conflicts, invalid selectors, or testing on a device where hover behaves differently.
Does :hover work the same on mobile devices?
Not always. Many touch devices do not support hover in the same way as desktop browsers, so important interactions should not depend only on :hover.
Should I style both :hover and ?
Mini Project
Description
Build a small interactive profile card with a link and a hidden action area that appears on hover. This project demonstrates how :hover works on both the element itself and its children, and gives you something practical to inspect in Chrome DevTools.
Goal
Create a card whose appearance changes on hover and reveals a hidden action button area that you can inspect using forced :hover state in Chrome DevTools.
Requirements
- Create a card component with a title, description, and action area.
- Hide the action area by default.
- Show the action area when the card is hovered.
- Change the card border or shadow on hover.
- Add a link inside the card with its own hover style.
Keep learning
Related questions
Angular ngClass Conditional Class Binding Explained
Learn how to use Angular ngClass for conditional classes, fix common binding mistakes, and understand why this template error happens.
CSS :not() Selector for Elements Without a Class or Attribute
Learn how to use the CSS :not() selector to target elements that do not have a specific class or attribute, with examples and common pitfalls.
CSS Font Scaling Relative to Container Size: %, em, rem, vw, and Responsive Text
Learn how CSS font scaling really works and how to make text responsive using %, em, rem, vw, clamp(), and media queries.