CSS property reference

W3C CSS Snapshot 2026

Look up syntax and common mistakes. Edit and run each example.

On this page

box-sizing: border-box

Count padding and borders within the declared 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>box-sizing: border-box</title>
  <style>
.card { box-sizing: border-box; width: 160px; padding: 12px; border: 2px solid teal; }
  </style>
</head>
<body>
<p class="card">Desk Lamp</p>
</body>
</html>

What to expect The whole box is 160px wide.

Common mistake Margins remain outside the declared width.

gap: 12px

Add space between neighboring grid or flex items.

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>gap: 12px</title>
  <style>
.row { display: flex; gap: 12px; }
.row > div { background: #d8efeb; padding: 6px; border: 1px solid teal; }
  </style>
</head>
<body>
<div class="row"><div>Pen</div><div>Notebook</div><div>Folder</div></div>
</body>
</html>

What to expect There is equal space between items.

Common mistake Use padding for room at the outside edges of the container.

max-width: 100%

Set an upper size bound so a wide card can shrink in a narrower container.

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>max-width: 100%</title>
  <style>
main { width: min(200px, 100%); outline: 1px dashed teal; }
.card { width: 320px; max-width: 100%; box-sizing: border-box; padding: 8px; background: #def5f5; }
  </style>
</head>
<body>
<main><p class="card">Desk Lamp</p></main>
</body>
</html>

What to expect The wide card shrinks to fit its 200px parent.

Common mistake Include padding and border in the cap with box-sizing: border-box.

overflow-wrap: anywhere

Allow a long word or URL to wrap to another line.

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>overflow-wrap: anywhere</title>
  <style>
.card { width: 125px; padding: 8px; border: 1px solid teal; overflow-wrap: anywhere; }
  </style>
</head>
<body>
<p class="card">https://example.com/shop/product-with-a-long-name</p>
</body>
</html>

What to expect The URL fits inside the narrow card in multiple lines.

Common mistake For a scrollable area, use overflow: auto.

Official references