# transform-box

> The `transform-box` CSS property defines the reference box used by the `transform` and `transform-origin` properties.

## How do I rotate an SVG element around its own center?

The property that sets the reference box for `transform` and `transform-origin`. Values like 'border-box', 'content-box', 'fill-box' or 'view-box' matter most for SVG, where 'fill-box' lets shapes rotate around their own center.

- Topic: Transformations
- Type: property
- Browser support: Chrome 64+, Chrome Android 64+, Edge 79+, Firefox 55+, Firefox Android 55+, Safari 11+, Safari iOS 11+

## Example

Wrong:

```css
.gear {
  transform-origin: center;
  animation: spin 2s linear infinite;
}
```

Right:

```css
.gear {
  transform-box: fill-box;
  transform-origin: center;
  animation: spin 2s linear infinite;
}
```

With 'fill-box', 'center' means the center of the shape, not the center of the SVG viewport.

## Common mistakes

- An SVG path spins around the top-left of the `<svg>` instead of its own center.

## Key points

- SVG elements set `transform-box: fill-box` before using `transform-origin: center`.
- HTML elements keep the default box, since 'fill-box' and 'view-box' mainly matter for SVG.

## Interview questions

### What is the default transform-box?

'view-box', so SVG transforms use the SVG viewport; HTML elements then use their border box.

### What is the difference between fill-box and stroke-box?

'fill-box' uses the shape's geometry, while 'stroke-box' also includes the stroke around it.

## Related cards

- [transform-origin](https://wonderium.dev/css/transform-origin.md)
- [transform](https://wonderium.dev/css/transform.md)
- [`<svg>`](https://wonderium.dev/html/svg.md)
- [stroke](https://wonderium.dev/css/stroke.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/transform-box
- Last updated: 2026-11-25
