# CSS: “background-position”: only “0” can be a “length”. You must put a unit after your number.

> Canonical HTML version: https://rocketvalidator.com/html-validation/css-background-position-only-0-can-be-a-length-you-must-put-a-unit-after-your-number
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `background-position` property has a number without a unit, such as `20`, and CSS only accepts a unitless number as a length when it is `0`.

`background-position` places a background image inside its element. Each offset is a length such as `20px` or `1.5em`, a percentage, or a keyword like `left` or `center`. CSS has no default unit, so `20` alone is not a length. One bare number triggers the error even next to a valid value: `right 20` and `50% 20` both fail.

Browsers in standards mode drop the declaration. The image then sits at the default position, the top left corner, or wherever an earlier rule put it.

The bare number often comes from a theme or page builder setting that prints an offset without `px`, or from a template that outputs a calculated number alone. Add the unit you meant. `0` is the one number that is valid without a unit, because zero is the same length in every unit.

## Invalid example

```html
<div style="background-image: url(hills.jpg); background-position: right 20;">
  <p>Welcome to the valley</p>
</div>
```

## Valid example

```html
<div style="background-image: url(hills.jpg); background-position: right 20px;">
  <p>Welcome to the valley</p>
</div>
```
