# flex

> The `flex` CSS property is a shorthand for `flex-grow`, `flex-shrink` and `flex-basis` that sets how a flex item grows, shrinks and sizes.

## What does flex: 1 mean in CSS?

The shorthand property that sets the `flex-grow`, `flex-shrink` and `flex-basis` properties for a flex item. It defines how a flex item should grow, shrink and be sized within a flex container, making it key to creating responsive layouts.

- Topic: Flexboxes
- Type: property
- Browser support: Chrome 29+, Chrome Android 29+, Edge 12+, Firefox 20+, Firefox Android 20+, Safari 9+, Safari iOS 9+

## Example

Wrong:

```css
.item {
  flex-grow: 1;
}
```

Right:

```css
.item {
  flex: 1;
  min-width: 0;
}
```

`flex: 1` also sets `flex-basis: 0`, so items share space equally, and `min-width: 0` lets them shrink below their content.

## Common mistakes

- Setting `flex: 1` on the container instead of its children.
- Items with `flex: 1` still overflow because of long words and no `min-width: 0`.

## Key points

- Equal-width items use `flex: 1` together with `min-width: 0` when they hold long text or code.
- The shorthand `flex` is used instead of setting `flex-grow`, `flex-shrink` and `flex-basis` one by one.
- `flex` is set on the flex items, not on the container with `display: flex`.

## Interview questions

### flex: 1 vs flex: auto: what is the difference?

`flex: 1` means `1 1 0`, so items get equal widths. `flex: auto` means `1 1 auto`, so items start from their content size and share the remaining space.

### What is the default value of flex?

The initial value is `0 1 auto`: items do not grow, can shrink, and start from their own size.

### What does flex: none do?

It sets `0 0 auto`, so the item keeps its size and neither grows nor shrinks.

## Related cards

- [flex-grow](https://wonderium.dev/css/flex-grow.md)
- [flex-shrink](https://wonderium.dev/css/flex-shrink.md)
- [flex-basis](https://wonderium.dev/css/flex-basis.md)
- [display](https://wonderium.dev/css/display.md)
- [min-width](https://wonderium.dev/css/min-width.md)

---

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