How to Customise CSS Element Badges in Google Chrome DevTools

Modern web front-end development relies on an intricate array of modern CSS layout specifications, container queries, and accessibility attributes. As developers inspect complex DOM trees containing hundreds of nested elements, quickly identifying which HTML nodes establish CSS Grid contexts, Flexbox containers, scroll containers, or popovers becomes difficult when scrolling through raw markup alone.

Google Chrome DevTools provides visual Element Badges directly inside the Elements panel DOM tree. These clickable inline badges—such as grid, flex, subgrid, scroll-snap, container, and popover—tag elements based on their active layout rules and trigger visual canvas overlays. However, on large-scale applications with deep DOM trees, having all badge types enabled simultaneously can clutter the inspector hierarchy. Chrome DevTools allows developers to configure which badges appear. This guide shows how to customise and configure CSS element badges in the Chrome DevTools DOM tree.

Understanding Chrome DevTools Element Badges

Element badges are small interactive pill buttons rendered adjacent to HTML opening tags inside the Elements tree. Clicking a badge toggles a visual canvas overlay on the live page.

The primary badge types supported in Chrome DevTools include:

  • grid: Indicates that the element establishes a CSS Grid container (display: grid or inline-grid). Clicking toggles line numbers, track sizes, and area names on the viewport.
  • subgrid: Flags nested grids participating in parent track alignments.
  • flex: Identifies CSS Flexbox containers (display: flex or inline-flex). Clicking displays alignment lines and item bounds.
  • scroll-snap: Marks elements configuring CSS Scroll Snap containers.
  • container: Highlights elements acting as CSS Container Query contexts (container-type: inline-size).
  • popover: Labels elements using the HTML Popover API or top-layer positioning.
  • slot: Flags Web Component Shadow DOM slot insertion points.

Accessing Badge Settings in Chrome DevTools

You can toggle badge visibility directly from the Elements tree context menu without navigating through deep global settings.

Step-by-Step Badge Configuration

  1. Launch Google Chrome and navigate to the web application you want to inspect.
  2. Open Developer Tools by pressing F12 (Windows/Linux) or Cmd+Option+I (Mac), or right-click any element and select Inspect.
  3. Ensure you are in the Elements panel.
  4. Inside the DOM tree view, right-click on any HTML node tag.
  5. In the contextual popup menu, hover over or click Badge settings….
  6. A floating Badge settings management overlay opens, listing all available badge types alongside individual toggle checkboxes.

Configuring Active and Inactive Badges

Inside the Badge Settings list, customize your layout debugging workspace to focus on the specific features relevant to your current project:

Enabling or Disabling Specific Badges

  • To hide flexbox indicators on a project that relies exclusively on CSS Grid, uncheck flex. All flex badges disappear from the DOM tree immediately, reducing visual noise.
  • To highlight responsive component containers while refactoring modular cards, ensure the container checkbox is enabled.
  • To debug top-layer dialogues and modal overlays, enable the popover badge to quickly locate dismissible components in the markup.

Click outside the Badge settings popup or click the small close button (✕) to persist your selections. Chrome DevTools remembers your badge preferences across browser restarts and separate tabs.

Interacting with Badges on the Live Viewport

Customising your badge layout enables efficient visual debugging workflows:

  1. Locate an element displaying a badge (for example, a grid badge next to <div class="catalog">).
  2. Click the grid badge directly in the DOM tree.
  3. The badge highlights in purple, and Chrome DevTools draws an interactive grid coordinate overlay directly over the live webpage on your screen.
  4. Click the badge again to turn off the overlay.
  5. Multiple badges can be engaged simultaneously (e.g. toggling both a parent grid overlay and a child flex overlay) to debug nested alignment conflicts visually.

Complementary Overlay Settings in the Layout Panel

While element badges toggle overlays on and off quickly, fine-tuning overlay visuals (such as grid line colors, track sizes, and area names) is managed in the companion Layout tab:

  1. In the right-hand sidebar of the Elements panel (alongside Styles and Computed), click the Layout tab.
  2. Under Grid overlays, select specific checkboxes to display:
    • Show line numbers: Prints numeric coordinate axes along tracks.
    • Show line names: Displays custom named grid lines.
    • Show track sizes: Displays resolved pixel or fraction units along rows and columns.
    • Show area names: Overlays named template area labels.
  3. Select the color swatch next to any container to customize its overlay contrast against your site’s dark or light background theme.

Troubleshooting Badge Display Anomalies

  • Badges Disappeared Completely: If no badges render despite active CSS rules, open Badge settings… and ensure checkboxes have not been disabled globally. Also verify that the element has valid computed styles applied (elements with display: none suppress layout badges).
  • Subgrid Badge Not Triggering: The subgrid badge appears only when an element defines grid-template-columns: subgrid or grid-template-rows: subgrid within an established parent grid container.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.