Skip to main content
HTML Validation

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

About This CSS Issue

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

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

Valid example

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

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
€5 / week

1K Weekly

1,000 monthly checks. Cancel anytime.

Get 1K Weekly →

Join teams across 40+ countries