In the Chrome devtools, Firefox devtools, Safari, Opera, etc., if I inspect an element I can see its bounding box nicely outlined when I mouse over the code for that element in the source panel. That's great. But what if I'd like to see how all (or most of) the elements on the page are laid out? For instance, maybe I'd like to see something like this:

enter image description here

In the Firefox "Style Editor" I've added these styles:

div { border: 1px dotted pink }
p   { border: 1px solid green }
a   { border: 2px solid yellow }
li  { border: 1px dashed cyan }
img { border: 1px solid purple}

(Chrome can't do this since it doesn't support the UAAG 2.0 web standard for accessibility). Since the user agent style sheet overrides the styles from the page, I see the kind of outlines I'm looking for.

Now this is just a hack, and perhaps is sufficient, but are there other tools that do this, or something in the devtools that I didn't find?

Note: I did find this answer regarding the "Show composited layer borders" under the Rendering menu option in Chrome, but it's not really what I'm looking for:

https://superuser.com/questions/774424/grid-overlay-showing-up-as-soon-a-i-launch-chrome-developer-tools

6

There are 6 answers

4
Purplejacket On BEST ANSWER

It turns out I was looking for a browser extension a friend had mentioned a long time ago: the "Web Developer" extension.

http://chrispederick.com/work/web-developer/

Here's what it looks like outlining the block level elements:

enter image description here

It's available for Chrome, Firefox, and Opera. Apparently not for Safari.

2
Rajan471 On

You dont have to edit User agent style sheet as you can do it using developer tools [F12].

You need to add this code

*{border: 1px solid #fff}
3
Prasad Madushan On

I use this way

*:hover { 
   outline:1px blue solid;
 } 
0
davimdantas On

If you are using Firefox Quantum:

https://addons.mozilla.org/en-US/firefox/addon/open-pesticide/?src=search

Open Pesticide by MatthewBaa

Outlines each element on the page to help you visualize their dimensions and overcome those annoying CSS layout issues. Requires zero permissions and completely open source.

0
Purplejacket On

Another useful concept came up this year, 2022:

* {
  background: rgb(0 100 0 / 0.1) !important;
}

The idea is that every element gets a certain amount of coloring so that we can visually determine how much overlapping space there is because multiple overlaps will become darker. It will look like this:

'Card 1' has too much space on the right side

The technique reveals that there is excess space on the right hand side of the card 1 h2 tag.

The above image was authored by Kevin Powell on his codepen.

He describes the whole concept in a very cogent YouTube video called The console.log of CSS which is under a minute long.

1
Arsen Khachaturyan On

If you are using Chrome, I found this extension that can be useful:

https://chrome.google.com/webstore/detail/outline-all-elements/nppiigcgjgghnpdflckpalmdmpnfglfa

Add CSS Outline property to all elements on the page for debugging CSS Layout. A Chrome Extension for adding CSS Outline property (with different colors) to all elements on the page.

Mainly, this is useful for debugging CSS Layout and discovering potential issues.