Debug a broken layout

W3C CSS Snapshot 2026

Start with the element that looks wrong. The browser’s Developer Tools show rules that match and the final values the browser calculated.

On this page

Read Styles and Computed

Right-click the teal-colored target and select Inspect. Styles shows the matching rules and crosses out a declaration when another wins. Computed shows the resolved values. Toggle a competing rule in DevTools to see its effect before editing the file.

How to try it Save this example as a new .html file, then open it in your browser. After a change, save and reload.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Read Styles and Computed</title>
  <style>
    .notice { color: purple; }
    .notice { color: teal; }
  </style>
</head>
<body>
<p class="notice">Your order is ready.</p>
<p>Your package is on the way.</p>
</body>
</html>

What to expect The first paragraph is teal. Disable the later color declaration in Styles; it becomes purple. Reloading restores the file’s styles.

Find a box that is wider than its parent

Overflow happens when content exceeds the available space. Inspect the parent and child widths first. For a box meant to shrink, max-width: 100% limits its width to the parent’s available width.

How to try it Save this example as a new .html file, then open it in your browser. After a change, save and reload.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Find a box that is wider than its parent</title>
  <style>
    .panel { width: 180px; outline: 2px solid purple; }
    .wide { width: 280px; background: #d6efea; }
  </style>
</head>
<body>
<div class="panel"><div class="wide">Product list</div></div>
</body>
</html>

What to expect The teal box extends past the purple boundary. Add max-width: 100% to .wide to fit it inside.

Let long text wrap inside a flex item

A long string with no spaces can force a flex item to stay wider than the row. Give that text item min-width: 0 so it can shrink, and use overflow-wrap: anywhere so the browser can wrap the string. Keep a separate button readable with flex-shrink: 0.

How to try it Save this example as a new .html file, then open it in your browser. After a change, save and reload.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Let long text wrap inside a flex item</title>
  <style>
    .toolbar { display: flex; gap: 8px; width: 240px; outline: 1px solid teal; }
    .reference { min-width: 0; overflow-wrap: anywhere; }
    button { flex-shrink: 0; align-self: start; }
  </style>
</head>
<body>
<div class="toolbar"><span class="reference">ITEM-2026-YANGON-0044-1C31B3B8097AE57E</span><button type="button">Save</button></div>
</body>
</html>

What to expect The entire reference wraps and the Save button fits beside it. Remove both text rules to reproduce the overflow.

Official references