Skip to main content

HTML Guide

CSS: “height”: The types are incompatible.

The value for the height property in your CSS must be a valid CSS length or percentage, or the keyword auto.

height in CSS accepts values such as px, em, rem, %, or the keyword auto. Incompatible values, like an unrecognized string or a missing unit (e.g., just height: 100;), will trigger this validation error. Always specify a valid unit unless using 0, which doesn’t require a unit, or use a percentage if the parent element has a defined height.

Correct usage examples:

<style>
  .box {
    height: 200px;
  }
  .container {
    height: 70%;
  }
  .image {
    height: auto;
  }
  .zero {
    height: 0;
  }
</style>

Incorrect usage examples:

<style>
  .bad {
    height: 100; /* missing unit */
  }
  .bad2 {
    height: big; /* invalid keyword */
  }
</style>

Always include a valid unit like px, %, em, or use auto for the height property.

Learn more:

Related W3C validator issues