Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

border-width — border thickness

border-width sets the thicknesses of the four physical border sides using one to four values. It does not set style or color; increasing the width alone will not display an ordinary border whose style is none.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

border-width: <line-width>{1,4};
<line-width> = <length [0,∞]> | thin | medium | thick

border-width is a shorthand for border-top-width, border-right-width, border-bottom-width, and border-left-width. It changes thickness only, not style or color. The property is not inherited.

One value applies to every side. Two mean top/bottom and right/left. Three mean top, right/left, and bottom. Four apply in this order: top, right, bottom, left. These are physical directions, independent of writing direction.

Allowed values are nonnegative lengths, including 0, and thin, medium, thick. Percentages and negative values are invalid. The referenced CSSWG drafts assign those keywords 1px, 3px, 5px, respectively; the example uses explicit lengths rather than depending on keyword implementation.

Each side's initial width is medium, but the initial border-style is none. With style none or hidden, that side's used width is 0. To display an ordinary border, set, for example, border-style: solid. A later border shorthand declaration can overwrite the widths.

Examples

<!doctype html>
<meta charset="utf-8">
<title>border-width</title>
<style>
  #box {
    border-style: solid;
    border-color: navy;
    border-width: 2px 4px 6px 8px;
  }
</style>
<div id="box">border-width</div>

Result

border-top-width: 2px
border-right-width: 4px
border-bottom-width: 6px
border-left-width: 8px

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources