HTML Guides for border-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.
The border-style property controls the visual pattern of a border — whether it appears as a solid line, a series of dots, dashes, or other decorative styles. Its valid values are: none, hidden, dotted, dashed, solid, double, groove, ridge, inset, and outset.
The keyword thick is a valid value for border-width, which controls how wide or heavy the border appears. It's one of three named width keywords: thin, medium, and thick. When thick is mistakenly used as a border-style value, the browser cannot interpret the declaration, and the border may not render at all or may fall back to unexpected defaults.
This is a common mix-up because people often think of a "thick border" as a single concept, but CSS separates the concern into two distinct properties: the style (what it looks like) and the width (how thick it is). Both must be set correctly for the border to display as intended. Without a valid border-style, most browsers default to none, meaning no border is visible regardless of other border properties.
To fix the issue, replace thick in your border-style declaration with a valid style keyword, and move thick to border-width if you want a heavier border. Alternatively, you can use the border shorthand to set width, style, and color in a single declaration.
Examples
Incorrect: using thick as a border style
<divstyle="border-style: thick;">This border will not render correctly.</div>
The value thick is not recognized for border-style, so the declaration is invalid.
Correct: separating style and width
<divstyle="border-style: solid;border-width: thick;">This has a thick solid border.</div>
Here, solid defines the border pattern and thick defines the border width — each value is used with the correct property.
Correct: using a specific pixel width
<divstyle="border-style: dashed;border-width:4px;">This has a 4px dashed border.</div>
You can use any length value (like 4px or 0.25em) for border-width instead of the thick keyword for more precise control.
Correct: using the border shorthand
<divstyle="border: thick solid #333;">This uses the border shorthand.</div>
The border shorthand accepts width, style, and color in any order. This is often the most concise way to define a border and avoids confusion between the individual properties.
The border-width property controls the thickness of an element's border. According to the CSS specification, its accepted values fall into two categories:
- Length values — any valid CSS length such as
1px,0.25em,2rem,3pt, or0.1cm. The value must not be negative. - Keywords — exactly three are defined:
thin,medium, andthick. These map to implementation-defined sizes but are guaranteed to maintain the relationshipthin ≤ medium ≤ thick.
A bare number like 5 (without a unit) is not valid, even though some browsers may silently accept it. Similarly, words like large, bold, normal, or color values like red are not valid border-width values. Percentage values (e.g., 10%) are also not accepted for border-width, unlike many other CSS properties that accept lengths.
This matters for several reasons. First, invalid CSS values cause the declaration to be ignored entirely, meaning the border may not render as intended — or may fall back to the initial value of medium, producing unexpected results. Second, relying on browser error-recovery behavior leads to inconsistent rendering across different browsers and versions. Third, valid CSS ensures your stylesheets are maintainable and predictable.
Common causes of this error include:
- Missing units — writing
border-width: 2instead ofborder-width: 2px. The only unitless length allowed in CSS is0. - Misspelled or invented keywords — using
large,small,normal, ornoneinstead ofthin,medium, orthick. - Wrong value type — accidentally using a color name, percentage, or other non-length value.
- Typos in units — writing
5xpinstead of5px.
To fix the issue, locate the offending border-width declaration and replace the invalid value with a proper CSS length (including its unit) or one of the three accepted keywords.
Examples
Invalid: using a non-existent keyword
<style>
.box{
border-style: solid;
border-width: large;/* "large" is not a valid border-width value */
}
</style>
<divclass="box">Content</div>
Fixed: using a valid keyword
<style>
.box{
border-style: solid;
border-width: thick;
}
</style>
<divclass="box">Content</div>
Invalid: missing unit on a number
<style>
.alert{
border: solid;
border-width:3;/* unitless number is not valid */
}
</style>
<divclass="alert">Warning</div>
Fixed: adding a proper unit
<style>
.alert{
border: solid;
border-width:3px;
}
</style>
<divclass="alert">Warning</div>
Invalid: using a percentage
<style>
.panel{
border-style: solid;
border-width:5%;/* percentages are not valid for border-width */
}
</style>
<divclass="panel">Panel</div>
Fixed: using a length value instead
<style>
.panel{
border-style: solid;
border-width:0.3em;
}
</style>
<divclass="panel">Panel</div>
Using multiple values with shorthand
The border-width property accepts one to four values (for top, right, bottom, left), and each must independently be valid:
<style>
.card{
border-style: solid;
border-width: thin 2px medium 1px;
}
</style>
<divclass="card">Card content</div>
Replace any invalid border-width value with a recognized CSS length (always including the unit, except for 0) or one of the keywords thin, medium, or thick to resolve the validation error.
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.
Pro Trial
Full Pro access. Cancel anytime.
Start Pro Trial →Join teams across 40+ countries