Skip to main content

HTML Guide

CSS: “height”: Too many values or values are not recognized.

The height property in your CSS containing invalid or too many values. The height property should have only one valid length, percentage, or keyword value.

Valid Values for height Property:

  1. Length values: px, em, rem, etc. (e.g., 100px, 10em)
  2. Percentage values: (e.g., 50%)
  3. Keyword values: auto, max-content, min-content, fit-content, inherit, initial, unset

Example of Incorrect Usage:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    .example {
      height: 100px 50px; /* Incorrect: Too many values */
    }
  </style>
  <title>Height Property Example</title>
</head>
<body>
  <div class="example">Content</div>
</body>
</html>

Example of Correct Usage:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    .example {
      height: 100px; /* Correct: One valid value */
    }
  </style>
  <title>Height Property Example</title>
</head>
<body>
  <div class="example">Content</div>
</body>
</html>

Learn more:

Related W3C validator issues