HTML Guides for border-top-width
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
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>
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.
1K Weekly
1,000 monthly checks. Cancel anytime.
Get 1K Weekly →Join teams across 40+ countries