Using Browser DevTools for CSS: Inspecting, Computed Styles and Live Editing
How to debug CSS with browser developer tools: inspecting elements, reading the Styles and Computed panes, spotting overridden and invalid declarations, the box model view, forcing states like :hover, layout overlays for flexbox and grid, emulating media features, and editing CSS live.
kvi5hnuCode Sprout team member12 min readOn this page
CSS problems are rarely about syntax. They're about which rule won, where a size came from, or why an element sits where it does. Every major browser includes developer tools (DevTools) that answer those questions directly, by showing the rules that apply to an element, the final values, and the boxes it produces. Learning them early saves more time than any other CSS skill. This article uses Chrome's DevTools, and notes where Firefox and Safari differ. Their panels have similar names and do the same jobs.
Opening DevTools
- Right-click an element on the page and choose Inspect. DevTools opens with that element selected. This is the fastest way in.
- Keyboard:
F12orCtrl+Shift+Ion Windows and Linux, andCmd+Option+Ion macOS.Ctrl+Shift+C/Cmd+Shift+Copens the element picker directly. - Safari needs the developer menu first: Settings > Advanced > Show features for web developers. Then use Develop > Show Web Inspector.
The panel for CSS is called Elements in Chrome and Edge, Inspector in Firefox, and Elements in Safari. It shows the HTML as a tree on one side and the styles of the selected element on the other.
The Styles pane: every rule that matches
The Styles pane (Firefox: Rules) lists every rule that applies to the selected element, highest priority first. For a paragraph inside a book card, it might show:
element.style { ← inline style attribute
}
.book-card p { site.css:42 ← your rules, most specific first
color: #333;
margin-block: 0.5rem;
}
p { site.css:3
margin: 0; ← struck through: overridden
line-height: 1.5;
}
p { user agent stylesheet
display: block;
margin-block-start: 1em; ← struck through
}
Inherited from div.book-card
.book-card { site.css:30
font-family: Georgia, serif;
color: #555; ← struck through: the element sets its own color
}
What to read from it:
- Order: rules are sorted the way the cascade sorts them (article 17), so the top rule wins any conflict.
- Struck-through declarations lost to a higher-priority rule. Finding the winning one is usually the answer to "why doesn't my style apply?"
- A warning icon and a struck-through declaration with a yellow triangle mean the declaration is invalid: an unknown property or a value the browser doesn't accept. Hover over the icon for the reason.
- Hovering a selector shows its specificity, such as
(0,1,1)(article 15), and hovering avar()shows its current value (article 27). - The file and line next to each rule (
site.css:42) link to the source. With source maps, that's your original Sass or unminified file. - "user agent stylesheet" marks the browser's defaults. They're why a
<p>has margins and an<h1>is bold before you write any CSS. - "Inherited from ..." sections show inherited properties from ancestors (article 16). Only inheritable properties appear there.
- Layer and scope labels: rules inside
@layer,@media,@container,@scopeand@supportsshow that context above the rule. That tells you why a rule with high specificity can still lose (article 20).
Editing live
Everything in the Styles pane is editable, and changes apply instantly:
- Click a value to change it. With a number selected,
↑and↓change it by 1,Shiftby 10, andAlt/Optionby 0.1. - Click the checkbox beside a declaration to turn it off and on. That's the quickest test of whether a declaration matters.
- Click after the last declaration to add a new one. Autocomplete lists valid properties and values.
- Click the
+icon to add a rule with a new selector. - Click a color swatch to open the color picker, which can convert between formats and shows contrast ratios against the background (article 35).
These edits are temporary: reloading the page discards them. Copy what works back into your source files. Chrome can save edits to disk if you connect a local folder in Sources > Workspace, but most people copy them by hand. In Chrome, the Changes drawer (open the ⋮ menu, then More tools > Changes) lists every edit you made, as a diff. Firefox has a Changes panel in the Inspector that does the same.
The Computed pane: the final values
The Computed pane shows each property's final value for the element, after the cascade, inheritance and conversions. It answers questions the Styles pane can't:
- What value did the element actually get? Relative units are converted, so
font-size: 1.25remappears as20px. - Where did it come from? Expand a property to see every declaration that tried to set it, with the winner first and a link to its rule.
- Properties you never set show their initial or inherited values. Check Show all to include them.
Use the filter box at the top to find one property quickly. At the bottom, Rendered fonts lists the fonts actually used to draw the element's text, which is how you check that a font stack or web font works (Firefox has a separate Fonts panel for this, article 82). The box model diagram above the list shows the element's content size, padding, border and margin. Hover over each part to highlight it on the page, and double-click a value to change it.
Highlighting boxes on the page
Hovering over an element in the HTML tree highlights it on the page: content in blue, padding in green, border in yellow and margin in orange. A tooltip shows its size, color and contrast, and accessibility information. When something has unexpected space around it, this shows immediately whether the space is the element's margin, its parent's padding or something else.

The tooltip's size, 240 × 81, is the border box: the 200px content width plus 14px of padding and 6px of border on each side. The margin is outside it.
Forcing states: :hover, :focus and others
Hover styles are awkward to inspect: moving the mouse to DevTools ends the hover. Instead, select the element and click :hov in the Styles pane. Check :hover, :active, :focus, :focus-visible, :focus-within, :visited or :target, and DevTools keeps the element in that state while you edit its rules.
The same button area also has .cls, which adds or removes classes on the element, useful for testing a variant such as .book-card--featured without editing the HTML.
Layout tools for flexbox and grid
Next to a display: flex or display: grid declaration, and next to the element in the HTML tree, DevTools shows a flex or grid badge. Click it to draw an overlay on the page:
- Grid overlays show line numbers, track sizes, gaps and area names (articles 66 to 70).
- Flexbox overlays show the main axis, free space and gaps (articles 61 to 63).
- Chrome's Layout tab and Firefox's Layout panel list every grid and flex container on the page, with settings for the overlays.

The overlay turns 120px 1fr 2fr into real numbers: the 2fr track is twice the 1fr track, and the gaps are not part of any track.
Chrome also has a flexbox editor and a grid editor: small icons next to display: flex and display: grid that let you click through justify-content, align-items and similar values to see each one's effect.
Other badges appear for container queries (container), scroll snap (scroll-snap), subgrid, and elements in the top layer such as open dialogs. Each one highlights the relevant boxes.
Emulating devices and preferences
- Device toolbar (
Ctrl+Shift+M/Cmd+Shift+M): resize the viewport to phone and tablet sizes to test media queries (article 76). Dragging the edge shows the current width. - Rendering drawer (in Chrome,
⋮> More tools > Rendering): emulateprefers-color-scheme: dark,prefers-reduced-motion,prefers-contrast,forced-colors, print media, and vision deficiencies such as blurred vision or color blindness. You can also toggle Paint flashing and Layout shift regions, which help with performance (article 111). In Firefox, the color scheme and print simulations are buttons in the Rules pane's toolbar. - The Animations drawer records CSS animations and transitions, so you can slow them down, replay them and scrub through them (article 109).
The CSS Overview and coverage
- CSS Overview (Chrome,
⋮> More tools > CSS overview) summarizes a page: every color used, font combinations, media queries, and contrast problems. It's a quick audit of an inherited codebase. - Coverage (
⋮> More tools > Coverage) shows how much of each stylesheet the current page uses. Large unused portions suggest splitting CSS per page.
Checking a rule from the console
The Console can answer questions about styles with JavaScript. Two useful one-liners:
getComputedStyle($0).display // $0 is the element selected in the Elements panel
CSS.supports("anchor-name: --a") // does this browser support a feature?
getComputedStyle() returns the same values as the Computed pane. CSS.supports() returns true or false, like an @supports query (article 80).
A debugging routine
When a style doesn't do what you expect, work through these questions in order:
- Does the rule match the element at all? Select the element. If your rule isn't in the Styles pane, the selector doesn't match: check class names, spelling and the element's actual position in the HTML.
- Is the declaration valid? A warning icon means the property or value is wrong, or unsupported in this browser.
- Is it overridden? If it's struck through, find the rule above it that sets the same property, then fix the specificity, order or layer (articles 15, 17 and 20).
- Is the property inherited, and is it supposed to be? Check the Computed pane to see where the value came from.
- Does the property apply to this kind of element? Some properties work only in certain contexts:
widthdoes nothing on an inline<span>,z-indexneeds a positioned or flex or grid item, andjustify-itemsdoes nothing in a flex container. DevTools in Chrome and Firefox shows a hint icon on such inactive declarations, explaining why.
What's current
- Inactive CSS hints: Chrome and Firefox both mark declarations that have no effect and explain why, such as "the display property of the parent element prevents
flex-growfrom having an effect". - Cascade layers,
@scopeand@containerare shown in the Styles pane above each rule. - Chrome's AI assistance panel can explain styling of the selected element in plain language. Treat its answers as suggestions and verify them in the Styles and Computed panes.
Common questions
I changed CSS in DevTools and it worked, but after reloading it's gone. Why? DevTools edits change the page in memory, not your files. Copy the change into your stylesheet, or check the Changes drawer for a list of everything you edited.
My rule doesn't appear in the Styles pane. What does that mean?
The selector doesn't match the element you selected. Common causes: a typo in a class name, case differences (.Card vs .card), selecting the wrong element in the tree, or a combinator that doesn't fit the real structure, such as .card > p when the paragraph is inside another div. It can also mean the stylesheet didn't load: check the Network panel.
The Computed pane shows 16px, but I wrote 1rem. Is something wrong?
No. The Computed pane shows resolved values, so relative units are converted to pixels. The Styles pane shows what you wrote.
What's the difference between the Styles and Computed panes? Styles shows the declarations, the rules as written, sorted by priority, including those that lost. Computed shows the result: one final value per property. Use Styles to fix the cause and Computed to confirm the result.
How do I inspect a tooltip or menu that disappears when I move the mouse?
Use the :hov toggles to force :hover or :focus on the element that shows it. For menus opened by JavaScript, use Emulate a focused page in the Rendering drawer, or pause the script with F8 while the menu is open and then inspect it.
Summary
- Right-click and Inspect opens DevTools with the element selected.
- The Styles pane lists matching rules in cascade order, strikes through overridden declarations, and flags invalid ones with a warning.
- The Computed pane shows final values, where each came from, and the box model diagram.
- Edits apply instantly but are lost on reload, so copy them back into your files.
:hovforces states such as:hoverand:focus-visible, and.clstoggles classes.- Flex, grid and container badges draw overlays that explain layouts.
- The device toolbar and Rendering drawer emulate screen sizes, color schemes, reduced motion and print.
- Debug in order: does the rule match, is it valid, is it overridden, is it inherited, and does it apply to this element?
Practice questions
A declaration in the Styles pane is struck through without a warning icon. What does that tell you, and where do you look next?
Answer
It's valid but lost the cascade to another declaration of the same property. Look higher in the Styles pane for the winning rule, or expand the property in the Computed pane, which lists every declaration that tried to set it, with the winner first.
You set width: 300px on a <span>, and nothing changes. DevTools shows the declaration with an info icon, not struck through. What's the likely explanation?
Answer
The declaration is valid and wins the cascade, but it's inactive: width doesn't apply to non-replaced inline elements. The hint explains that the element's display value prevents it from having an effect. Change the span to display: inline-block or block, or put it in a flex or grid container (article 5).
How can you check whether a menu's hover color comes from your stylesheet or from a framework's stylesheet, when the menu item only has that color while hovered?
Answer
Select the menu item, open the :hov panel and check :hover. DevTools keeps the hover state, so the hover rules appear in the Styles pane with their file names and line numbers. The top rule that sets color is the one that wins.
Which tool would you use to see how a page looks when the user's operating system is in dark mode, without changing your system settings?
Answer
The Rendering drawer in Chrome (Emulate CSS media feature prefers-color-scheme: dark), or the dark mode simulation button in Firefox's Rules pane. Both make prefers-color-scheme: dark match for that tab only.
Previous: CSS Syntax: Rules, Declarations, Comments, and How Browsers Handle Errors
Next: Elements and Boxes: Block, Inline, Replaced Elements and the display Property

More in CSS Course
Quiz: CSS Delicate Details
Twenty-five questions on the edge cases that surprise experienced developers: invalid custom properties, shorthands that reset values, layer order with !important, containing blocks, margin collapsing, specificity of :is() and :where(), intrinsic minimum sizes, and more, each checked in Chrome.
Quiz: CSS Interview Questions
Thirty front-end interview questions: cascade, specificity and layers, box model and margin collapsing, stacking contexts, positioning, flexbox and grid, responsive design, custom properties, performance, accessibility, modern selectors and architecture.
Quiz: CSS Course Final Exam
Thirty questions across the whole CSS course: syntax and error handling, selectors, the cascade and layers, values and units, color, the box model, backgrounds, positioning, flexbox, grid, responsive design, typography, generated content, effects, transforms, motion and architecture.
Quiz: CSS Architecture, Tooling and Debugging (CSS Part 17)
Twenty questions on modular CSS and BEM, layering a stylesheet, design tokens and theming, pattern libraries and safe refactoring, preprocessors and build tools, the at-rules reference, and debugging common CSS problems.
Discussion
Sign in to ask a question or share what you learned.