CSS Outline Debugger Bookmarklet
Outline every element on a page with a color based on its nesting depth to spot overflow, stray margins and layout bugs fast. Click again to remove. Free.
On a phone? Use Copy code, then save it as a bookmark's URL — step-by-step guide.
CSS Outline Debugger draws a thin outline around every element on the page, colored by how deeply it is nested. The body's direct children get red, their children orange, then yellow, green, cyan, blue and so on through ten colors. In a second you can see every box, how they are nested and where one ends and the next begins.
It is the classic front-end trick for finding layout bugs: the element that causes horizontal scrolling, a margin collapsing out of its parent, an invisible wrapper adding extra space, a flex item that refuses to shrink or text overflowing its container. Because it uses outline instead of border, the boxes do not change size and the layout does not shift while you debug.
A short message tells you how many elements were outlined and the maximum depth. Click the bookmark again to remove all outlines.
What it does
- Outlines every element inside
bodywith a 1px outline - Ten colors cycle by nesting depth (red, orange, yellow, green, cyan, blue, violet, pink, teal, gray)
- Uses
outlinewith a negative offset, so layout and sizes do not change - Reports the number of elements and the maximum nesting depth
- Second click removes all outlines
How to install the CSS Outline Debugger bookmarklet
- Show your bookmarks bar. Press
Ctrl+Shift+Bon Windows/Linux orCmd+Shift+Bon a Mac (Chrome, Edge, Brave, Firefox). In Safari choose View › Show Favorites Bar. - Drag the blue button above onto the bar. That's it — the bookmark now holds the code.
- Open any website and click the bookmark to run it on that page. Click it again to close it.
Can't drag (phone, tablet, locked-down browser)? Copy the code below, create any bookmark, then edit it and paste the code as its URL. See how to add a bookmarklet in every browser.
How to use it
- Open the page with the layout problem and click CSS Outline Debugger.
- Look for boxes that stick out past the viewport or their parent, or that are larger than their content.
- Use the colors to see which level a box belongs to; the same color means the same depth.
- Click the bookmark again to switch the outlines off.
Finding common layout bugs
For horizontal scrolling, scroll right and look for the outline that extends past the edge: that element, or its widest child, is the culprit. Unexpected gaps usually come from margins of an inner box poking out of its parent, which the outlines make obvious. Very deep nesting (colors cycling several times) often signals wrapper-heavy components; Element Counter gives the exact depth. Elements inside shadow DOM components and iframes are not outlined, and pages that already use outlines for focus styles will be overridden while the debugger is on.
Bookmarklet code
This is the exact code inside the button above (1,855 characters). It runs only in your browser and sends nothing to us. Paste it into the Bookmarklet Decoder to read it formatted.
Frequently asked questions
Why outline and not border?
Borders add width and height and shift the layout. Outlines are drawn outside the box model, so what you see is the real layout.
What do the colors mean?
Each color is a nesting level below body. After ten levels the colors repeat.
How do I turn it off?
Click the bookmark again or reload the page.
Related bookmarklets
Show CSS grid tracks and flexbox containers on any page, plus an adjustable 12-column layout grid for checking alignment.…
Hover any element to see its tag, ID and CSS classes, then click to copy a unique CSS selector. A free bookmarklet for…
Count DOM elements, nodes and nesting depth on any page, with a sortable per-tag table and Lighthouse DOM-size…
Show the live viewport width and height, device pixel ratio and the current Tailwind, Bootstrap and page CSS breakpoint…