# CSS: “border-top-width”: X negative values are not allowed.

> Canonical HTML version: https://rocketvalidator.com/html-validation/css-border-top-width-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 `border-top-width` declaration has a negative value, and a border can't be thinner than zero.

`border-top-width` sets the thickness of an element's top border. It accepts `0`, a positive length such as `2px` or `0.1em`, or one of the keywords `thin`, `medium` and `thick`. A browser drops a `border-top-width` declaration with a negative value, and the element keeps whatever top border width it gets from other rules. Adding `!important` doesn't change that: the declaration is still invalid, and the validator still reports it.

To remove the top border, set `border-top-width` to `0`. If the negative width was meant to pull the element up over the content above it, use a negative `margin-top`, which CSS allows. The `border-top` and `border-width` shorthands follow the same rule, and each one has its own message.

## Invalid example

```html
<p>The previous paragraph ends here.</p>
<div class="banner" style="border-top-width: -20px;">
  Banner content
</div>
```

## Valid example

```html
<p>The previous paragraph ends here.</p>
<div class="banner" style="border-top-width: 0; margin-top: -20px;">
  Banner content
</div>
```
