> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# `<fit-content>`

APISummary
`fit-content()` currently supports for [`width`], [`height`] and [grid layout] properties ([`grid-template-columns`], [`grid-template-rows`], [`grid-auto-columns`], and [`grid-auto-rows`]).

When used as a [`width`] or [`height`], take the larger value between the following two: the maximum size of the content and the smaller value specified in `fit-content()`.

`fit-content` is equivalent to `fit-content(auto)`, and the specified value of auto is the same as the corresponding axis length of the parent element.

## Example

```css
width: fit-content;
height: fit-content(200px);
grid-template-columns: fit-content;
grid-template-rows: fit-content;
grid-auto-columns: fit-content;
grid-auto-rows: fit-content;
```

## Compatibility

**Compatibility Table**

**Query:** `css.data-type.fit-content`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/css/data-type/fit-content.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| fit-content | Yes (targetSdkVersion 2.0) | Yes (3.4) | Yes (targetSdkVersion 2.0) | No | No | Yes |

**`fit-content`**

<code>&lt;fit-content&gt;</code>

**Specifications:**
- [https://drafts.csswg.org/css-sizing-4/#valdef-width-fit-content](https://drafts.csswg.org/css-sizing-4/#valdef-width-fit-content)


[`width`]: /next/api/css/properties/width.md

[`height`]: /next/api/css/properties/height.md

[`grid-template-columns`]: /next/api/css/properties/grid-template-columns.md

[`grid-template-rows`]: /next/api/css/properties/grid-template-rows.md

[`grid-auto-columns`]: /next/api/css/properties/grid-auto-columns.md

[`grid-auto-rows`]: /next/api/css/properties/grid-auto-columns.md

[grid layout]: /next/guide/ui/layout/grid-layout.md
