Codesnippet.dev
</>

Why does height property not work in CSS

Sometimes it may appear that CSS property height does not work in certain cases.

Example: https://codepen.io/vorcak/pen/poeEeaj

However, when reading the specification we learn that height property does not apply for inline, non-replaced elements.

The 'height' property does not apply. The height of the content area should be based on the font, but this specification does not specify how.

Source: https://www.w3.org/TR/CSS22/visudet.html#inline-non-replaced

The usual solution is to change the display property to something like inline-block if possible.