# CSS: “padding”: X negative values are not allowed.

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

A `padding` declaration has a negative value, and padding can't be less than zero.

Padding is the space between an element's content and its border, so CSS only accepts zero or a positive length or percentage for it. A browser drops any `padding` declaration with a negative value, and the element keeps whatever padding it gets from other rules.

The shorthand takes one to four values, and any of them can be the negative one. In `padding: 16px -8px`, the left and right padding are `-8px`, so the validator reports that value. When a declaration has more than one negative value, the message only quotes the first, so check every value in it. The `padding-top`, `padding-right`, `padding-bottom` and `padding-left` properties follow the same rule, and each one has its own message.

To fix the error, change each negative value to `0` or a positive length. If the negative value was meant to pull the element closer to its neighbors, or past the edges of its container, use a negative `margin` instead, which CSS allows.

## Invalid example

```html
<div class="card" style="padding: 16px -8px;">
  Card content
</div>
```

## Valid example

```html
<div class="card" style="padding: 16px 0; margin: 0 -8px;">
  Card content
</div>
```
