fit the content width to container in css code example Example 1: css width fit to content width: fit-content; Example 2: css div width fit content display: inline-block;