About This CSS Issue
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
<div class="card" style="padding: 16px -8px;">
Card content
</div>
Valid example
<div class="card" style="padding: 16px 0; margin: 0 -8px;">
Card 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?
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