# Containing block

*noun*

say it: **“kun-TAY-ning BLOK”** **/kənˈteɪnɪŋ blɑk/**

The box an element measures itself against: its percentage sizes and its top, right, bottom and left are worked out from this box, usually a nearby ancestor.

## What is a **containing block**?

The **containing block** is the box an element's percentages and positions are measured from, usually its nearest suitable ancestor.

```css
.card { position: relative; }   /* the containing block for... */
.card .badge { position: absolute; top: 0; }   /* ...this badge */
```

## In a sentence

- “Once the card had position: relative, it became the badge's **containing block**, and the badge sat in the card's corner instead of the page's.”

Level: Master · [More CSS terms at this level](https://www.ask-codey.com/glossary?category=css&level=5)

Updated: November 9, 2026

Source: https://www.ask-codey.com/glossary/containing-block
