# CSS: “line-height”: X negative values are not allowed.

> Canonical HTML version: https://rocketvalidator.com/html-validation/css-line-height-x-negative-values-are-not-allowed
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

Negative values for the CSS `line-height` property are invalid and browsers reject them.

The `line-height` property sets the height of each line box, so a negative value has no meaning and violates the CSS specification. Valid values are `normal`, a unitless multiplier like `1.5`, a length like `24px` or `1.5em`, or a percentage like `150%`. A unitless number is usually the best choice, since it scales with the element's font size and avoids the inheritance quirks that fixed lengths can cause.

This error usually appears when `line-height` is set inline through the `style` attribute, where the W3C validator catches it during HTML validation. A common cause is a calculation in a template or script that produces a negative number and writes it into the markup.

To fix it, replace the negative value with a positive one, or use `normal` for the browser's default spacing. Tighter lines are fine as long as the value stays positive, such as `line-height: 0.9`.

## HTML examples

### Invalid: negative line-height value

```html
<p style="line-height: -0.5em;">
  Paragraph text
</p>
```

### Valid: positive value or normal

```html
<!-- Unitless multiplier, scales with font size -->
<p style="line-height: 1.5;">
  Paragraph text
</p>

<!-- Browser default spacing -->
<p style="line-height: normal;">
  Paragraph text
</p>
```
