css height fit content code example

Example 1: css width fit to content

width: fit-content;

Example 2: css height property

/* <length> values */
height: 300px;
height: 25em;

/* <percentage> value */
height: 75%;

/* Keyword values */
height: max-content;
height: min-content;
height: fit-content(20em);
height: auto;

/* Global values */
height: inherit;
height: initial;
height: unset;

Example 3: css div width fit content

display: inline-block;

Example 4: css height auto vs 100

<div style="height:50px">
    <div id="innerDiv" style="height:auto">
          <div id="evenInner" style="height:10px">
          </div>
    </div>
</div>

Example 5: css height auto vs 100

<div style="height:50px">
    <div id="innerDiv" style="height:100%">
    </div>
</div>