Loading

T3 Browser DevTools · Lesson 1

The Elements panel

Opening DevTools and what each panel is for; the DOM tree, and why it differs from your source; the Styles tab, with what every mark means; the Computed tab and the box model; and a sure method for any CSS mystery.

  • open DevTools in several ways, and name what each panel is for
  • read the DOM tree, and explain why it can differ from your HTML
  • read the Styles tab: which rules reached an element, which won, and what each mark means
  • use the Computed tab and the box model to see final values and real sizes
  • follow a sure method for a CSS mystery, trying each fix live first
About 60 minutesChecked against Google Chrome on the laptop (the kit renders every HTML block in it, and the DevTools step describes its panels) 155 (2026-11-06)Play this lesson's games

The back cover

Every page you open is built twice: once by its author in a file, and once by the browser in memory. When the two disagree, guessing wastes hours. DevTools lets you look straight at what the browser built and why.

These pages show how to open DevTools and what each panel is for. They show the DOM tree the browser really made, the Styles tab with every rule and who won, and the Computed tab with the final numbers. They end with a sure, step-by-step method for any CSS mystery.

Before you start

The story: The panel that lied

A baker on Inkwell Lane has a panel that says "Fresh bread" in grey. His sheet says it should be red, and he has shown the sheet to everyone on the street. Corin reads it twice, agrees that it is perfect, and suggests changing it anyway, just to see.

Ilse will not hear of it. She walks you to the Lens-grinders' Row, where the shop windows are full of small brass eyepieces. Behind the counter sits Ottilie Sen, who does not look up from the glass in her hand.

"Everyone reads the sheet," she says. "Nobody looks at the panel. Look first. Guess afterwards." She holds out a lens. Through it, the panel opens like a clock with its back off.

So far you have written HTML and CSS, then looked at the page and hoped. When the page looked wrong, you could only guess why. Every browser has a set of tools built in for exactly this moment, and they show you what the browser really did with your code. This step teaches them, one panel at a time, starting with the panel you will use most. It builds on these ideas; each has a tiny example.

What you already knowA tiny exampleWhere it comes back
HTML is a tree of elements.A li inside a ul inside a body.The Elements panel shows that tree.
The browser forgives mistakes in HTML.A missing closing tag still shows a page.It repairs them, and the panel shows the repair.
A rule has a selector and declarations.p { color: red; }The Styles tab lists every rule that reached an element.
The cascade picks a winner.An id beats a class; a later rule beats an earlier equal.The losers are shown crossed out.
Some properties pass down to children.A colour set on body reaches a p.Those appear under "Inherited from".
A browser drops what it cannot read.color: bluee;The tab marks it with a warning.
A valid property can still do nothing.width on an inline span.The tab shows it pale, with a hint.
The box model.Content, padding, border, margin.The Computed tab draws it with real numbers.
States such as :hover.a:hover { color: red; }The panel can hold a state on while you look.
Measuring what was drawn.getBoundingClientRect().The checks here confirm what the panels will show you.

By the end of this lesson you will be able to:

  • open DevTools in several ways, and name what each panel is for;
  • read the DOM tree, and explain why it can differ from your HTML;
  • read the Styles tab: which rules reached an element, which won, and which marks mean what;
  • use the Computed tab and the box model to see final values and real sizes;
  • follow a sure method to solve a CSS mystery, trying each fix live before writing it down.

How to follow this lesson

Use Chrome on a laptop or desktop computer. Each block below has a Run button that shows its page. To look inside that page, right-click it and choose Inspect, then follow the steps in the text. The notes under each block, marked Checked in Chrome, confirm by measuring the page what the panels will show you.

In one line

DevTools shows what the browser really did with your code, so you can stop guessing; you need the tree of HTML, the cascade and the box model.

Opening the lens: DevTools

At a glance

A doctor does not guess what is wrong from the outside alone; an X-ray shows what is really there. DevTools is an X-ray for web pages: a set of panels built into the browser that show what it did with a page, and let you try changes on the spot.

It opens with a right-click and Inspect, or with Ctrl + Shift + C, J or I. Each panel answers one kind of question. Nothing you change there is saved to your files, so you can try anything.

Take a guess: If you change a colour in DevTools and then reload the page, is the change still there?

A doctor does not guess what is wrong from outside alone. An X-ray shows what is really there. DevTools is an X-ray for web pages.

DevTools

Short for developer tools: a set of panels built into the browser that show what it did with a page, and let you try changes on the spot. Chrome, Edge, Firefox and Safari all have them; this step uses Chrome's.

Three ways in

WayWindows or LinuxMacIt opens
Inspect one thingright-click it, then Inspectthe samethe Elements panel, with that element selected
The pick toolCtrl + Shift + CCmd + Option + Cthe Elements panel, ready to pick an element on the page
The ConsoleCtrl + Shift + JCmd + Option + Jthe Console panel
The last panel you usedF12 or Ctrl + Shift + ICmd + Option + Iwhichever panel you had open

A memory aid

C for CSS, J for JavaScript, I for "I choose". Hold Ctrl and Shift, or Cmd and Option on a Mac, then press the letter.

The right-click is the one to learn first. It answers the most common question in web work: "What is this thing, and who is styling it?" The pick tool does the same without the menu. Move the pointer over the page and each element lights up, with a small label giving its tag, its class and its size. Click to choose it.

Inspect finds the top element at the point you click. The browser offers the same search to scripts, as document.elementFromPoint(), and the check below uses it, so you can trust that it agrees with what you will see.

<!DOCTYPE html>
<style>
  body { margin: 0; }
  .price { font-size: 24px; color: teal; }
</style>
<h1>Masala tea</h1>
<p>Today: <span class="price">₹15</span></p>

Checked in Chrome

  • the top element at the price is the span with class price, which is what Inspect will select

The panels

DevTools opens beside or below the page. Along its top is a row of tabs, one for each panel. You do not need them all at once; this step takes the main ones in turn.

PanelWhat it showsAsk it whenLesson
Elementsthe page's tree and its CSSsomething looks wrongthis one
Consolemessages from the page, and a place to type codesomething does not workthe next one
Networkevery file the page asked forsomething is missing or slowthe third
Sourcesthe page's code, with a way to pause itthe code does the wrong thingthe fourth
Applicationwhat the page has stored in the browserit remembers too much or too littlethe fifth
Performancewhere the time goesthe page feels slowthe sixth

The device toolbar, the small phone and tablet button at the top left of DevTools, is the subject of the last lesson. If a panel you want is hidden, the » button at the end of the row shows the rest.

Two helpers: the Command Menu and the Drawer

Press Ctrl + Shift + P, or Cmd + Shift + P on a Mac, to open the Command Menu. Type a few letters of what you want, such as "dark" or "ruler", and press Enter. You met it in earlier lessons for emulating dark mode and less motion. It reaches almost everything, so you need not remember where each setting lives.

Press Esc in DevTools to open the Drawer, a strip along the bottom that can hold a second tool, usually the Console, under whichever panel you are in. You can read the page's messages while you look at its CSS.

Nothing you do here is saved

This is the most important fact about DevTools, and it is why you can be bold with it. DevTools changes the copy of the page in your browser's memory. It does not change your files, and it does not change the site for anyone else. Reload the page and everything you did is gone.

Forgetting to write it down

You find the fix in DevTools, it looks perfect, and you reload to admire it. It vanishes. Keep your editor open beside the browser, and copy each fix into your file as soon as it works.

Worked example 1

A shop's page shows a price in the wrong colour, and you have never seen this page's code. Find out which element holds the price and what class it has, without reading the source.

What we have: a page you did not write, and one thing on it you want to know about

What we need: the element's tag and its class

The plan: right-click the price and choose Inspect: the panel opens with that element selected

  1. Right-click the price on the page, then choose Inspect.
  2. The Elements panel opens, and one line of the tree is highlighted. That line is the element, here <span class="price">.
  3. The Styles tab beside it now lists that element's rules, so you know where to look next.
<!DOCTYPE html>
<style>
  body { margin: 0; }
  .sale .price { color: grey; }
</style>
<div class="sale">
  <h2>Basmati rice, 5 kg</h2>
  <p><span class="price">₹450</span></p>
</div>

Checked in Chrome

  • the element at the price is a span
  • and it is grey, as the Styles tab will explain

A span with the class price, found in two clicks, with no source reading.

Check: the check asked the browser for the element at that point, and it named the same span.

When you are stuck: opening DevTools

No Inspect in the menu: right-click the page itself, not the browser's own bars. On a Mac in Safari, developer tools must be switched on first; this step uses Chrome.

The shortcut does nothing: try F12, and on a laptop try Fn + F12. Or use the three-dot menu, then More Tools, then Developer Tools.

A panel is missing: look under the » button, or find it by name in the Command Menu.

Your turn

Which shortcut opens the Console in Chrome on Windows?Tap to reveal
  1. J for JavaScript.

Ctrl + Shift + J.

You delete a heading in DevTools, then reload. What happens?Tap to reveal
  1. Where did the change happen?

It comes back: DevTools changes only the copy in memory.

Which panel lists every file a page asked for?Tap to reveal
  1. Files travel over the network.

The Network panel.

Did you know?

The first Web Inspector, 2006

The Elements panel and the Styles pane are older than they look. On 16 January 2006, Timothy Hatcher introduced the Web Inspector, a new addition to WebKit. It let you browse the live DOM hierarchy, it highlighted each node on the page as you selected it, and its Style pane showed all the CSS rules that applied to the chosen node.

Why it fits here: The panels this topic opens do the same jobs that first inspector did.

Source: WebKit blog: Introducing the Web Inspector

A new Chrome every four weeks

DevTools changes faster than most guides about it. Google moved Chrome to a new stable version every four weeks, down from six, and planned Chrome 94, due on 21 September 2021, as the first release on that schedule. Each release has its own notes, such as What's new in DevTools (Chrome 120). So a button may sit somewhere other than an older guide says.

Why it fits here: It is why this topic teaches what each panel is for rather than where each button sits: buttons move, jobs stay.

Sources: Chrome for Developers: Speeding up Chrome's release cycle; Chrome for Developers: What's new in DevTools (Chrome 120)

In one line

DevTools opens with a right-click and Inspect, or Ctrl + Shift + C, J or I; each panel answers one kind of question, and nothing you change there is saved to your files.

The DOM tree: what the browser really built

At a glance

An architect draws a plan; the builders quietly fix a door drawn in the wrong place, and later the owner adds a shelf. Your HTML is the plan, and the house that stands is the DOM, the tree of objects the browser built from it. The Elements panel shows that tree.

It holds what the browser added or repaired and what scripts changed later, so it can differ from your source. You can edit it freely to test an idea, because a reload brings back the page from your files.

Take a guess: If you write a table row without a tbody, will the Elements panel show a tbody anyway?

An architect draws a plan for a house. The builders, finding a door drawn in the wrong place, quietly correct it, and later the owner adds a shelf. The house that stands is not quite the plan. Your HTML is the plan, and the browser's copy of the page is the house that stands. The Elements panel shows you the house.

DOM

The Document Object Model: the tree of objects the browser builds from your HTML. Each element, and each piece of text, is a node in that tree. The browser draws the page from the DOM, not from your file, and scripts change the DOM as the page runs.

So the tree can differ from your source. The browser adds what the rules of HTML require, repairs what you got wrong, and shows whatever scripts have changed.

What the browser adds

<!DOCTYPE html>
<table id="prices">
  <tr><td>Rice</td><td>₹60</td></tr>
</table>

Checked in Chrome

  • you wrote no tbody, but the browser added one, and the Elements panel shows it
  • so the tr is not a direct child of the table

What the browser repairs

<!DOCTYPE html>
<div id="a"><p>Hello<div>Rice</div></p></div>
<ul id="b"><li>Dal<li>Atta</ul>

Checked in Chrome

  • a p cannot hold a div, so the p is closed early, and the stray closing tag makes an empty p
  • each li is closed for you

That first repair surprises people. You wrote one paragraph, and the tree holds two, one empty. An unexplained gap on a page often turns out to be an empty element like that one, and only the tree shows it.

What scripts change

<!DOCTYPE html>
<ul id="stalls"></ul>
<script>
  document.querySelector("#stalls").innerHTML = "<li>Rice</li><li>Dal</li>";
</script>

Checked in Chrome

  • the source has an empty ul, but the tree holds two li: most pages of the modern web are built this way
View page sourceThe Elements panel
showsthe file as the server sent itthe DOM as it is now
includes repairsnoyes
includes changes made by scriptsnoyes, and it updates as they happen
opens withCtrl + Uright-click, Inspect

A memory aid

Source is the plan; Elements is the building. When the two disagree, the building is what the visitor sees.

Finding your way around

To do thisDo this
open or close a nodeclick the small arrow beside it, or press the Right or Left arrow key
move up and down the treepress the Up or Down arrow key
see where a node is on the pagehold the pointer over it in the tree: the page lights it up, with its size
search the treepress Ctrl + F in the panel, then type text, a CSS selector such as .price, or an XPath
bring a node into viewright-click it, then Scroll into view

The search box takes CSS selectors, which makes it a test of a selector as well as a search: type your selector, and the count shows how many elements it matches. If it says 0, your rule cannot be reaching anything.

Changing the tree

To changeDo this
the textdouble-click it in the tree, type, press Enter
an attributedouble-click the attribute name or value
the tagdouble-click the tag name
a whole pieceright-click, then Edit as HTML
the orderdrag a node to a new place
whether it showsselect it and press H to hide it; press again to bring it back
whether it existsselect it and press Delete

Why would you do this, if none of it is saved? To test ideas in seconds. How does the layout cope with a very long product name? Double-click the name and paste one in. Would the menu be better after the search box? Drag it there. Is this banner the thing covering the button? Hide it and see.

Holding a state on

A hover style disappears the moment your pointer moves to DevTools to read it. To hold a state on, right-click the node, choose Force state, then :hover. The Styles tab's :hov button does the same. Now you can study the style at leisure. It works for :active, :focus, :visited and :focus-within too.

From the tree to the Console

Whatever node you have selected is called $0 in the Console. Select a node, press Esc for the Drawer, and type $0 to get it back, ready to ask questions of it.

Worked example 2

A table's rows should be pale yellow. The sheet says table > tr { background-color: lightyellow; }, and the rule does nothing. Find out why, and fix it.

What we have: a rule with a child selector that matches nothing

What we need: the reason, and a selector that works

The plan: look at the tree: the tree shows what the selector really has to match, which may differ from the source

  1. Inspect a row. The tree reads table, then tbody, then tr.
  2. The browser added a tbody, so the tr is a child of the tbody, not of the table. The selector table > tr matches nothing.
  3. Search the tree for table > tr to confirm: 0 results. Then try tbody > tr: 2 results.
<!DOCTYPE html>
<style>
  table > tr { background-color: pink; }
  tbody > tr { background-color: lightyellow; }
</style>
<table>
  <tr class="row"><td>Rice</td></tr>
  <tr><td>Dal</td></tr>
</table>

Checked in Chrome

  • the first selector matches nothing
  • the second matches both rows
  • and the row is pale yellow

The browser added a tbody. Write tbody > tr, or the plainer table tr.

Check: the selector counts in the check are the counts the search box shows: 0 and 2.

Worked example 3

A page has an unexplained gap of about 16 pixels under a paragraph, and the HTML is one line: a p holding a div. Find the gap's cause.

What we have: a gap with no clear source, and a p holding a div

What we need: what is really in the tree

The plan: inspect the gap: the tree shows the page as built, not as written

  1. Look at the tree. There are three nodes where the source has two: a p, a div and an empty p.
  2. Hold the pointer over the empty p. The page lights up a thin band: it has no height of its own, but its margins are still there.
  3. The cure is in the HTML: a p cannot hold a div, so make the outer element a div.
<!DOCTYPE html>
<style>
  body { margin: 0; }
  div { height: 20px; }
</style>
<section id="wrong"><p>Note<div>Rice</div></p></section>
<section id="right"><div>Note<div>Rice</div></div></section>

Checked in Chrome

  • the wrong version has two p in the tree, one empty
  • the right version has none

A hidden empty paragraph, made by the browser's repair. Use a div as the outer element.

Check: the tree counts in the check match what the panel shows.

When you are stuck: the DOM tree

The tree does not match your file: that is normal; the browser added, repaired or a script changed something.

Cannot find an element: press Ctrl + F in the panel and search by text or selector.

A hover style will not stay: force the state with :hov.

Your turn

You wrote a table with no tbody. Does the tree show one?Tap to reveal
  1. The browser adds what the rules require.

Yes.

Which shows content added by a script: View page source or the Elements panel?Tap to reveal
  1. Which shows the page as it is now?

The Elements panel.

How do you keep a :hover style on while you study it?Tap to reveal
  1. The hov button.

Force the state, with :hov or the right-click menu.

Did you know?

The DOM became a standard in 1998

The name DOM comes from a W3C standard. The Document Object Model Level 1 became a W3C Recommendation on 1 October 1998. It defined the DOM as a platform- and language-neutral interface that lets programs and scripts access and update the content, structure and style of documents while they are open.

Why it fits here: The tree this topic shows in the Elements panel is that same object model, read by DevTools.

Source: W3C: Document Object Model Level 1

Every node has a number

Each node in the tree carries a number, its nodeType, fixed by the DOM standard. An element is 1, a piece of text is 3, a comment is 8 and the whole document is 9. Three numbers, 5, 6 and 12, are marked legacy in the standard. The Elements panel draws these same nodes, element by element, as its tree.

Why it fits here: The tree in this topic is made of these nodes: elements, text and comments, each with its own number.

Source: WHATWG: DOM Standard

In one line

The Elements panel shows the DOM, the tree the browser built: it holds what the browser added or repaired and what scripts changed, so it can differ from your source, and you can edit it freely to test ideas.

The Styles tab: every rule, and who won

At a glance

A tailor who gets instructions from four people keeps them all on one sheet, in order of who has the last word, and strikes out the ones that lost. The Styles tab is that sheet for one element: every rule that reached it, strongest first.

A crossed-out line lost to a stronger rule. A warning sign means the browser could not read the line. A pale line with an icon is valid but needs something else before it can work.

Take a guess: If a line in the Styles tab is crossed out, did the browser fail to read it, or did it lose?

Imagine a shirt for which four people gave the tailor instructions: the customer, his mother, the shop's manager, and the printed order form. A careful tailor keeps every instruction on one sheet, in order of who has the last word, and strikes out those that lost. The Styles tab is that sheet for one element.

Styles tab

The part of the Elements panel that lists, for the selected element, every CSS rule that reached it, with the rule that has the last word at the top. Beside each rule is the file and line it came from.

Reading it from the top

SectionWhat it is
element.stylestyles written on the element itself, in its style attribute; these usually win
your ruleseach rule that matches, most powerful first, each with a link such as style.css:14
user agent stylesheetthe browser's own defaults, such as the bold of a heading
Inherited from bodyproperties that passed down from an ancestor

What the marks mean

This table is the heart of the lesson. Each look in the tab tells you something different.

What you seeWhat it meansWhat to do
a line through a declaration, with no iconoverridden: a stronger rule wonfind the winner higher up
a line through it, with a warning iconinvalid: an unknown property or a bad valuecheck the spelling
pale text, with an information iconinactive: valid, but other properties stop it workinghold the pointer on the icon for the reason
a pale selectorunmatched: one selector in a list does not match this elementnothing, unless you expected a match
italic textnot editable, such as the browser's own defaultswrite your own rule to change it
pale text under Inherited from, with no iconthat property does not pass down by defaultnothing

A memory aid

Crossed out means lost; a warning means misspelt; pale with an icon means it needs something else.

Overridden: a stronger rule won

<!DOCTYPE html>
<style>
  .title { color: red; }
  #hero h1 { color: grey; }
</style>
<div id="hero"><h1 class="title">Fresh bread</h1></div>

Checked in Chrome

  • the heading is grey: the Styles tab lists #hero h1 first, and crosses out .title's red

Hold the pointer over a selector in the tab, and a tooltip shows its specificity, written as three numbers such as (1, 0, 1). Compare them, and you know why one beat the other: here one id and one type, against one class.

Invalid: the browser could not read it

<!DOCTYPE html>
<style>
  p { colour: red; }
  h2 { color: bluee; }
</style>
<h2>Offers</h2>
<p>Rice</p>

Checked in Chrome

  • colour is not a CSS property, so the whole line is crossed out, with a warning
  • and bluee is not a colour, so its value is crossed out

The British spelling colour is the classic: it is right in English and wrong in CSS, and every Indian learner writes it once. The warning icon is how you find it in a second.

Inactive: valid, but it needs something else

<!DOCTYPE html>
<style>
  body { margin: 0; }
  .box { width: 200px; justify-content: center; }
  span { width: 200px; }
</style>
<div class="box"><span>Rice</span></div>

Checked in Chrome

  • justify-content is set to center, yet the span stays at 0: it needs display: flex, and the tab says so
  • width: 200px is set on the span, yet it is drawn far narrower: an inline box takes no width

These are the hardest bugs to see by reading, because each line of the sheet is correct. Nothing is misspelt, and nothing is beaten. The rule is valid and has no effect. Hold the pointer on the information icon, and DevTools tells you, in words, what it needs.

Trying changes

To do thisDo this
switch a declaration off and onhold the pointer over the rule, and untick the box beside the declaration
change a valueclick it and type
nudge a numberclick it, then press Up or Down; add Shift for 10, Alt for 0.1
add a declarationclick the space after the last one in a rule
add a whole new ruleclick the + button at the top of the tab
add or remove a classclick .cls, then type a class name
pick a colourclick the small square beside it
find one propertytype its name in the Filter box
go to the rule in its fileclick the link at the right of the rule

The tick box is the quickest experiment there is. Is this rule the one causing the trouble? Untick it and look.

Worked example 4

The baker's heading should be red. The sheet has .title { color: red; }, and the heading is grey. Find out why, and choose a fix.

What we have: a rule that seems right, and a heading that disagrees

What we need: the winning rule, and a change that makes the heading red

The plan: inspect the heading, find the red rule, and see how it is marked

  1. Inspect the heading. In the Styles tab, color: red has a line through it, and no warning. So it is overridden, not misspelt.
  2. Look higher up. #hero h1 { color: grey; } is there, not crossed out. It wins.
  3. Hold the pointer over each selector: (1, 0, 1) against (0, 1, 0). An id is stronger than any number of classes.
  4. Try the fix live: click the grey and type red. The heading turns red. Then make the change in the file.
<!DOCTYPE html>
<style>
  .title { color: red; }
  #hero h1 { color: red; }
</style>
<div id="hero"><h1 class="title">Fresh bread</h1></div>

Checked in Chrome

  • with the winning rule changed, the heading is red

#hero h1 beat .title on specificity. Change the winning rule, and do not reach for !important.

Check: the heading now reads red, and the winning rule is the one that was changed.

Worked example 5

A menu's links should sit in the centre of the bar. The sheet says .bar { justify-content: center; }. The line is not crossed out, and the links stay at the left. What is wrong?

What we have: a valid, unbeaten line that does nothing

What we need: what the line needs, and the fix

The plan: a line that is neither crossed out nor winning anything shows as pale with an icon; read the hint

  1. Inspect the bar. The declaration is pale, with an information icon.
  2. Hold the pointer on the icon. It says that justify-content has no effect, because the element is not a flex or grid container.
  3. Add display: flex live, in the same rule. The links move to the centre.
<!DOCTYPE html>
<style>
  body { margin: 0; }
  .bar { display: flex; justify-content: center; width: 400px; }
  .bar a { width: 100px; }
</style>
<div class="bar"><a href="#a" class="one">Home</a></div>

Checked in Chrome

  • with display: flex, the 100 pixel link sits at 150, the centre of 400

The bar needs display: flex. The line was valid, and it had nothing to act on.

Check: the link's position moved from 0 to 150 once the container was a flex box.

When you are stuck: the Styles tab

Your rule is not in the list at all: the selector does not match, or the file did not load; test the selector in the tree's search box.

Crossed out with no icon: look upward for the winner, and compare specificity with the tooltip.

Pale with an icon: hold the pointer on the icon and read it.

Your turn

A declaration has a line through it and a warning icon. What does that mean?Tap to reveal
  1. Warning means misspelt.

It is invalid: an unknown property or a bad value.

A declaration has a line through it and no icon. What does that mean?Tap to reveal
  1. It lost.

It is overridden by a stronger rule.

How do you switch one declaration off to test it?Tap to reveal
  1. There is a box beside it.

Untick its box in the Styles tab.

Did you know?

Layers in the cascade

The cascade gained a new step in 2022. Cascade layers, the @layer rule, came to Chromium 99, Firefox 97 and Safari 15.4 Beta, to give more explicit control of CSS files and prevent conflicts of specificity. Between layers, the standard says, a normal rule in the last layer wins. DevTools can show each rule's cascade layer in the Styles pane.

Why it fits here: It adds one more reason to this topic's question of who won: a rule can lose because of its layer.

Sources: Chrome for Developers: Cascade layers are coming to your browser; W3C: CSS Cascading and Inheritance Level 5; Chrome for Developers: What's New In DevTools (Chrome 99)

Two kinds of pale text

Pale text in the Styles tab means one of two things. Chrome's own guide says properties that are valid but have no effect, because of other properties, are shown pale with information icons: they are inactive because of CSS logic, not because of the cascade. Pale properties without an icon are a different case: in the Inherited from sections, properties that do not inherit by default are shown in pale text.

Why it fits here: It sharpens this topic's rule: pale with an icon needs something else; pale without one was never passed down.

Source: Chrome for Developers: Find invalid, overridden, inactive, and other CSS

In one line

The Styles tab lists every rule that reached an element, strongest first: crossed out means it lost, a warning means the browser could not read it, and pale with an icon means it is valid but needs something else.

The Computed tab: the final answer

At a glance

The Styles tab is the whole argument; the Computed tab is the verdict. For each property it gives the one value the browser finally used, in plain pixels and plain colours, after every rule, every inherited value and every percentage has been worked out.

The arrow beside a value names the rule that set it. Its box model diagram shows the real sizes of the content, padding, border and margin, and the page lights up each layer when you point at it.

Take a guess: If a width is written as 50%, does the Computed tab show 50% or a number of pixels?

The Styles tab is the whole argument. The Computed tab is the verdict: for each property, the one value the browser finally used, in plain pixels and plain colours, after every rule, every inherited value and every percentage has been worked out.

Styles tabComputed tab
showsthe rules as you wrote themthe final values the browser used
losersshown, crossed outnot shown
shorthandsas written: margin: 10px split up: margin-top: 10px and so on
relative valuesas written: font-size: 70%worked out: font-size: 14px
ask itwhy this value?what value, exactly?
<!DOCTYPE html>
<style>
  body { font-size: 20px; }
  .small { font-size: 70%; padding: 1em; margin: 10px; }
</style>
<p class="small">Delivery is free above ₹499.</p>

Checked in Chrome

  • 70% of 20 is the 14px the Computed tab shows
  • 1em here is 14px
  • and the margin shorthand appears as four separate sides

Reading the tab

To do thisDo this
find one propertytype it in the Filter box
see what set a valueclick the arrow beside the property: it lists each source, winner first
jump to that ruleclick the file link beside it
see every property, set or nottick Show all
sort them into familiestick Group

The arrow is the fastest route from a mysterious value to its cause. Suppose a heading is 13 pixels and you have no idea why. In the Styles tab you might scroll past twenty rules. In the Computed tab, filter for font-size, open the arrow, and the winning rule is named.

The box model diagram

At the top of the Computed tab is a set of nested boxes: margin outside, then border, then padding, then content in the middle, each with its real numbers. The Styles tab has the same diagram in its sidebar, opened with the Show sidebar button. This is the box model you learned, drawn for this one element.

<!DOCTYPE html>
<style>
  body { margin: 0; }
  .card { width: 200px; padding: 10px; border: 2px solid teal; margin: 20px; }
</style>
<div class="card">Masala tea</div>

Checked in Chrome

  • the box is drawn 224 wide: 200 + 10 + 10 + 2 + 2, the numbers in the diagram
  • and it starts 20 in, the margin

Hold the pointer over each layer of the diagram, and the page lights up that layer on the real element: blue for content, green for padding, orange for margin. Double-click a number to change it, and the page responds at once.

The page lights up too

Hold the pointer over a node in the tree and the same colours appear on the page. An orange band tells you at a glance that a gap is margin, and whose margin it is.

The diagram also settles arguments about gaps. Two boxes, one with a bottom margin of 30, the next with a top margin of 20: is the gap 50? Hold the pointer over each. The two orange bands overlap, because margins between blocks collapse.

<!DOCTYPE html>
<style>
  body { margin: 0; }
  .first { height: 10px; margin-bottom: 30px; }
  .second { height: 10px; margin-top: 20px; }
</style>
<div class="first"></div>
<div class="second"></div>

Checked in Chrome

  • the second box starts at 40: 10 tall, then 30, not 50: the margins collapsed to the larger

Worked example 6

A card set to width: 100% with padding: 20px is wider than its column, and the page scrolls sideways. Use the box model diagram to explain it, then fix it.

What we have: a card that overflows a 400 pixel column

What we need: the numbers that explain it, and a fix

The plan: select the card and read the diagram: width applies to the content, so padding is added on top

  1. The diagram's middle box reads 400: the content alone is the column's full width.
  2. The padding adds 20 on each side, so the card is drawn 440 wide.
  3. Try box-sizing: border-box in the Styles tab: the middle box falls to 360, and the card is 400 wide.
<!DOCTYPE html>
<style>
  body { margin: 0; }
  .column { width: 400px; }
  .wide { width: 100%; padding: 20px; }
  .fits { width: 100%; padding: 20px; box-sizing: border-box; }
</style>
<div class="column">
  <div class="wide">Rice</div>
  <div class="fits">Dal</div>
</div>

Checked in Chrome

  • without the fix: 440 wide, 40 past the column
  • with box-sizing: border-box: 400

width applied to the content, and the padding came on top. Add box-sizing: border-box.

Check: the widths measured 440 and 400, as the diagram says.

When you are stuck: the Computed tab

A value you cannot explain: filter for it, then open the arrow to see which rule set it.

A gap you cannot explain: hold the pointer over the boxes and look for an orange band.

A property is missing from the list: tick Show all.

Your turn

Which tab shows the final font size in pixels when you wrote 70%?Tap to reveal
  1. The verdict.

The Computed tab.

Which colour does the page show for margin when you hold the pointer over a node?Tap to reveal
  1. Blue, green, and one more.

Orange.

A box is 300 wide, with padding of 10 and a border of 1 and the usual content box sizing. How wide is it drawn?Tap to reveal
  1. Both sides of each.

300 + 20 + 2 = 322.

Did you know?

You write red, it says rgb

The Computed tab speaks a stricter language than you write. Write color: red, and the computed value is the matching sRGB colour; the CSS Color standard says such colours are written out in the rgb() or rgba() form. So the Computed tab, like getComputedStyle, reports rgb(255, 0, 0) for red. Your words go in, and the browser's numbers come out.

Why it fits here: It is why a value in this topic's Computed tab may look unlike the line you wrote, while meaning the same thing.

Source: W3C: CSS Color Module Level 4

Computed is not quite computed

The word computed has a history. The script that reads these values, getComputedStyle(), was first defined to return computed values. Then the meaning of computed value changed between versions of CSS, while old scripts still needed the old answers. So the CSSOM standard gave those answers a new name of their own: resolved values.

Why it fits here: It explains why the numbers in this topic's Computed tab are called resolved values in the standards.

Source: W3C: CSS Object Model

In one line

The Computed tab gives the final value of every property, and the arrow beside it names the rule that set it; its box model diagram shows real sizes, and the page lights up each layer when you point at it.

Look first: a method for any CSS mystery

At a glance

A good doctor asks questions in a fixed order, because the order finds the cause fastest. The same order solves any CSS mystery, and it never starts by changing your code: first inspect the element, then look for your rule in the Styles tab.

Is the rule there at all? Is it crossed out? Is it pale? Then read the numbers in the Computed tab. Try the fix live in DevTools, and only when it works, copy it into your file.

Take a guess: When a CSS rule seems to do nothing, what should you check before changing any code?

A good doctor asks questions in a fixed order, because order finds the cause fastest. The same order works for every CSS mystery, and it never starts by changing your code.

StepAskIf so
1Inspect the element. Is this the element you thought it was?you may be styling its parent, or a neighbour
2Is your rule in the Styles tab at all?if not, the selector does not match or the file did not load
3Is your line crossed out, with a warning?fix the spelling or the value
4Is it crossed out, with no icon?find the winner above it, and change that, or give your rule more weight
5Is it pale, with an icon?read the hint: the rule needs something else
6Is it applied, and the page still looks wrong?go to the Computed tab and the box model: the sizes will explain it
7Have you found it?try the fix live, then copy it into your file

A memory aid

Is it the element? Is it listed? Is it crossed out? Is it pale? Then the numbers. And only then, change your file.

Step 2 is where many hours are lost. If your rule is not listed, no amount of changing its value will help. The two usual causes are a selector that does not match, which the tree's search box tests in a moment, and a stylesheet that never arrived, which the Network panel will show you in a later lesson.

SymptomLook at first
the colour or font is wrongthe Styles tab: is it crossed out?
a gap you cannot explainthe box model, and the orange band
the box is the wrong sizethe Computed tab: width, box-sizing
a flex or grid property does nothingthe Styles tab: pale, with an icon?
something cannot be clickedInspect at that spot: what is really on top?
a thing has vanishedthe tree: is it there? Then the box model: is it 0 tall?
fine on hover onlyforce the state with :hov

Worked example 7

A "Buy" button looks perfect, and clicking it does nothing. Its code is fine: it works on another page. Use the method to find out why.

What we have: a button that will not take a click, and sound code

What we need: what is receiving the click

The plan: step 1: is it the element you think it is? Right-click where the button is, and see what Inspect selects

  1. Right-click the button and choose Inspect.
  2. The tree highlights not the button but a div, <div class="glow">, a see-through decoration placed over the card.
  3. So the click goes to the div. The button was never the element at that point.
  4. Press H on the div to hide it, and try the button: it works. That proves the cause.
  5. The lasting fix: pointer-events: none on the decoration, so that clicks pass through it.
<!DOCTYPE html>
<style>
  body { margin: 0; }
  .card { position: relative; width: 200px; height: 100px; }
  .glow { position: absolute; inset: 0; }
</style>
<div class="card">
  <button class="buy">Buy</button>
  <div class="glow"></div>
</div>

Checked in Chrome

  • (the slip: at the button's spot, the top element is the see-through div)
<!DOCTYPE html>
<style>
  body { margin: 0; }
  .card { position: relative; width: 200px; height: 100px; }
  .glow { position: absolute; inset: 0; pointer-events: none; }
</style>
<div class="card">
  <button class="buy">Buy</button>
  <div class="glow"></div>
</div>

Checked in Chrome

  • with pointer-events: none, the button is found at that spot, and takes the click

A see-through div lay on top of the button. Give it pointer-events: none.

Check: the browser's own answer to "what is at this point?" changed from the div to the button.

When you are stuck: CSS mysteries

Lost in the middle: go back to step 1 and take the steps in order.

You keep changing the file and nothing happens: check that you are editing the file the page really loads; the link beside the rule names it.

Still lost: reduce the page. Delete nodes in the tree until the problem goes away; the last thing deleted is part of the cause.

Your turn

Your rule is not in the Styles tab at all. Name the two usual causes.Tap to reveal
  1. A selector, and a file.

The selector does not match, or the file did not load.

Which is the first question of the method?Tap to reveal
  1. Before any rule.

Is this the element you thought it was?

A button cannot be clicked. What do you try first?Tap to reveal
  1. What is really on top?

Inspect at that spot, to see which element is really there.

Did you know?

When the whole page is odd

One CSS mystery has nothing to do with your rules. The HTML standard says that DOCTYPEs are required for legacy reasons: without one, browsers tend to use a different rendering mode, incompatible with some specifications, known as quirks mode. Chrome 90 began to report quirks mode in DevTools' Issues tab. So when sizes and spacing make no sense at all, read the first line of the file.

Why it fits here: It adds one question to this topic's method: before blaming a rule, make sure the page is not in quirks mode.

Sources: WHATWG: HTML Standard, The HTML syntax; Chrome for Developers: What's New In DevTools (Chrome 90)

The detective's rule

Detectives use the same method as this topic. A CSS mystery yields to their habit: rule out, one by one, what cannot be the cause. In The Sign of the Four, first published in February 1890, Sherlock Holmes asks: "How often have I said to you that when you have eliminated the impossible, whatever remains, however improbable, must be the truth?"

Why it fits here: This topic's method works by elimination: the wrong element, the missing rule and the crossed-out rule are ruled out in turn.

Sources: Wikisource: The Sign of the Four, Chapter 6; Wikisource: The Sign of the Four

In one line

Solve any CSS mystery in order: is it the right element, is the rule listed, is it crossed out, is it pale, then read the numbers; try the fix live, then copy it into your file.

Where it is used

Working developers keep this panel open all day. These are the everyday uses.

What you learnedWhere it is usedA real example
Inspectfinding out what anything islearning how a site you admire built its menu
the DOM treepages built by scriptsreading the real structure of a shop built with React
the Styles tabevery CSS bugfinding the rule that beat yours in a large stylesheet
trying changes livedesign decisionstesting three shades of a button with a client beside you
the box model diagramspacing problemsfinding which margin makes a gap
force statehover and focus stylesfixing a dropdown that vanishes as you move to it
editing text in the treetesting a layoutpasting a very long name into a card to see if it breaks

Mistakes and debugging

These are the slips everyone makes with this panel.

1. Changing the file before looking

You guess, edit, save, reload, and repeat. The fix: find the cause in DevTools first, and try the fix there.

2. Losing your work

A perfect fix in DevTools is gone at the next reload. The fix: copy it into your file as soon as it works. Right-click a declaration for Copy all CSS changes.

3. Trusting the source

View page source shows the plan, not the building. The fix: use the Elements panel to see what the page really holds.

4. Writing selectors for the source

A selector such as table > tr matches nothing, because the browser added a tbody. The fix: write selectors for the tree, and test them in its search box.

5. Reaching for !important

<!DOCTYPE html>
<style>
  #hero h1 { color: grey; }
  .title { color: red !important; }
</style>
<div id="hero"><h1 class="title">Fresh bread</h1></div>

Checked in Chrome

  • (it works today, and the next person who must change this colour will need another !important)

It wins the fight and starts a war. The fix: change the winning rule, which the tab has already found for you.

6. Inspecting the wrong element

The text you see is often inside a span inside a link inside a div, and the style you want may be on any of them. The fix: walk up the tree with the Up arrow key, watching the page light up.

7. Not switching off the cache

You saved your file, yet the old style still shows, because the browser kept a copy. The fix: with DevTools open, press Ctrl + Shift + R to reload without the cache; the Network lesson shows a lasting switch.

The debugging corner: the tree as a test bench

When a page is too tangled to reason about, use the tree to shrink it. Delete a section, and see if the bug remains. If it remains, the section was innocent. If it goes, you have found where to look. Reload and you have everything back, so deleting costs nothing.

Quick card

The lesson on one card.

Every kind of case in the lesson

<!DOCTYPE html>
<style>
  body { margin: 0; color: navy; }
  .title { color: red; }
  #hero h1 { color: grey; }
  p { colour: red; }
  .bar { width: 200px; justify-content: center; }
  .card { width: 200px; padding: 10px; border: 2px solid; margin: 20px; }
</style>
<div id="hero"><h1 class="title">Fresh bread</h1></div>
<p>Baked this morning.</p>
<div class="bar"><span>Menu</span></div>
<div class="card">Masala tea</div>
<table><tr><td>Rice</td></tr></table>

Checked in Chrome

  • overridden: red is crossed out, and grey wins
  • invalid: colour is crossed out with a warning, so the navy of body comes through, Inherited from body
  • inactive: pale, with a hint, and the span stays at 0
  • the box model: 200 + 20 + 4 = 224
  • and the tree holds a tbody you never wrote
To do thisDo this
inspect one thingright-click, Inspect
open Elements, ready to pickCtrl + Shift + C
open the ConsoleCtrl + Shift + J
open the last panelF12 or Ctrl + Shift + I
run any commandCtrl + Shift + P
open the DrawerEsc
search the treeCtrl + F in the panel, by text or selector
hide a nodeselect it, press H
hold a hover:hov in the Styles tab
add a class.cls in the Styles tab
find what set a valueComputed tab, filter, open the arrow
the selected node, in the Console$0

And the rule of the Row: look first, guess afterwards.

The story: The rule that lost

Through the lens you see the panel's real frame, and beside it every rule that reached the words, in order. The red rule is there. A line runs through it. A later rule, three screens down the sheet, had beaten it.

You change the winning rule on the lens itself, and the words turn red at once. Nothing is broken, because the lens changes only what you see. Then you make the same change in the baker's sheet.

Ottilie nods, still not looking up. "Now you have seen it," she says. "What did your guess cost you? Nothing, this time."

Reagents gathered: Elements panel, DOM tree, Styles tab, Computed tab, box model, Inspect.

Sources

  • Chrome DevTools documentation (Page content CC BY 4.0, code samples Apache 2.0 (the footer of its pages, read 2026-11-06); reused with credit)
  • MDN Web Docs (Prose CC BY-SA 2.5 or later; code samples added since 2010-08-20 CC0 (its licensing page, read 2026-10-26); reused with credit)