Skip to content
engineering workbench.by StudyPort Academy
All errors
browser · DEBUG LIBRARY

The Styles pane is editing the wrong box

Locate the failed assumption, reproduce it, then repair the cause.

What actually caused it

DevTools shows the element you selected, not the element you meant. Overlapping boxes, a pseudo-element, or an iframe make it easy to edit a rule for a parent while looking at a child. A declaration that is crossed out has already lost the . Changing its numbers does not change the computed box.

The computed pane and the box-model diagram in the Elements sidebar show the used padding, border, and size. The Styles pane shows candidates. If the rule you expect is missing, the class is not on this node, the stylesheet did not load, or you are inspecting a different document.

The Console is a different tool. A query is a problem. A crossed-out width is a problem. Checking only one of them leaves the other mistake in place.

Minimal reproduction

A rule that already lost

/* #title wins, so this color is crossed out */
.card { color: #e2e8f0; }
#title { color: #f8fafc; }

Editing .card does nothing while the id rule matches.

The fix

Select the node with the inspector so the highlight on the page matches the row in the tree. Confirm the document context if the node is inside an iframe. Edit the declaration that is not crossed out, or change the markup so the selector you want is the one that matches.

Use the computed when the question is the size, and the Styles pane when the question is which rule won. Reload with the Network tab if the stylesheet you are editing is not the one the page received.

Change the declaration that wins

.card { color: #e2e8f0; }
/* Prefer dropping the id hook over adding !important. */
.title { color: #f8fafc; }

Confirm the node before reading its box

const card = document.querySelector(".card");
console.log(card ? card.className : "missing");