For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/css/data-type/fit-content.md.
Lynx
  • English
  • <fit-content>

    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

    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

    LCD tables only load in the browser

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.