Question

How to Inspect :hover State in Chrome DevTools

cssgoogle-chromebrowserhovergoogle-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.

Take Quiz

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

  1. Open DevTools.
  2. Inspect the element.
  3. In the Elements panel, select the element.
  4. Open the Styles pane.
  5. Click :hov or the state toggle control.
  6. Check :hover.

Chrome will now keep the element in hover state so you can inspect:

  • matched CSS rules
  • overridden rules
  • computed styles
  • layout changes

You can do the same for buttons, menu items, cards, and other interactive elements.

Example with a button:

<button class="save-btn">Save</button>
.save-btn {
  background: #eee;
  border: 1px solid #ccc;
}

.save-btn:hover {
  background: #dff0ff;
  border-color: #3399ff;
}

If you force :hover in DevTools, you can inspect the button while the hover styling stays active.

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:

  1. The page loads.
  2. The browser sees the .profile-link rule and gives the link color: black.
  3. The browser also reads .profile-link:hover, but it does not apply it yet.
  4. When the pointer moves over the link, the browser checks whether the :hover condition is true.
  5. Since it is true, the browser applies the hover rule.
  6. The link becomes green and bold.
  7. If you move your mouse away, the :hover condition becomes false and the browser removes those styles.

Now in Chrome DevTools:

  1. Select the <a> element in the Elements panel.
  2. Click the pseudo-state toggle such as :hov.
  3. Enable :hover.
  4. Chrome acts as if step 4 is permanently true.
  5. You can now inspect the green color and bold text in the Styles and Computed panels.

This is especially useful when the hover state triggers more complex effects like:

  • showing a hidden child element
  • animating opacity
  • changing position or transform
  • opening a dropdown menu

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.

Take Quiz

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 :hover selector 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 :hover with :focus and :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.

Another common pattern is using hover with guard-like CSS design:

.button {
  background: gray;
}

.button:hover {
  background: blue;
}

.button:disabled,
.button.disabled {
  background: lightgray;
  cursor: not-allowed;
}

In a real codebase, you may need to check whether disabled styles correctly prevent interactive hover behavior.

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.

4. Confusing :hover with :active

  • :hover means the pointer is over the element
  • :active usually means the element is being pressed or clicked

They are different states and often need different styles.

5. Hover state disappears while moving the mouse

This is exactly why the forced-state feature exists. Use the :hov control instead of trying to keep your mouse still.

6. Ignoring hidden layout changes

Hover sometimes changes more than color.

.card:hover {
  transform: scale(1.05);
}

Check computed styles, box model, and child elements too, not just the visible color changes.

Comparisons

Here is a comparison of common interactive pseudo-classes:

Pseudo-classWhen it appliesCommon use
:hoverPointer is over the elementLink and button hover styles
:activeElement is being pressedPressed button feedback
:focusElement has focusForms, keyboard navigation
:focus-visibleFocus is visible and should be shownAccessible keyboard focus rings
:visitedLink has been visitedStyling visited links with privacy limits

:hover vs :focus

  • :hover is usually mouse or pointer-based
  • :focus is important for keyboard users
  • Good UI often styles both, not just hover

Example:

a:hover,
a:focus {
  color: orange;
}

Forced state in DevTools vs real user interaction

ApproachBenefitLimitation
Real mouse hoverShows actual behaviorHard to inspect because state may disappear
Forced :hover in DevToolsEasy to debug stylesDoes not fully simulate every user environment

Using both is often best: test the real behavior first, then freeze the state for inspection.

Take Quiz

Cheat Sheet

selector:hover {
  /* hover styles */
}

Quick rules:

  • :hover applies 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 :focus for 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:

  1. Inspect element
  2. Select node in Elements panel
  3. Click :hov
  4. Enable :hover
  5. Check Styles and Computed tabs

Edge cases:

  • Hover may affect child elements
  • Touch devices may not support hover the same way
  • :visited has browser privacy restrictions
  • Transitions may make hover changes appear gradual

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 :focus?

Usually yes. :hover helps pointer users, while :focus or :focus-visible helps keyboard users and improves accessibility.

Take Quiz

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.
Take Quiz

Keep learning

Related questions

View more