CSS propertyBox model

border-width

Sets the thickness of a border.

Initial value
medium
Inherited
No
Animatable
yes, as a length
Applies to
all elements
JavaScript
element.style.borderWidth = "4px"
On this page

Example

#
CSS
.tab.active {
  border-bottom-width: 3px;
  border-bottom-style: solid;
  border-bottom-color: #a78bfa;
}
Preview

Definition and usage

#

The border-width property sets the thickness of the border line. It accepts lengths or the thin, medium, and thick keywords, whose exact thickness depends on the browser.

Like other edge shorthands, it takes one to four values: for all sides, for vertical and horizontal, or separately for each edge.

The width is only visible when the border has a style other than none and hidden.

Syntax

#
Syntax
border-width: thin | medium | thick | <length> (1-4 values);

Values

#
  • thin

    A thin line, usually 1px.
  • medium

    A medium line, usually 3px. The default value.
  • thick

    A thick line, usually 5px.
  • 2px 8px

    vertical horizontal

    Thin on top and bottom, thick on the sides.

Values in practice

#

thin

A thin line, usually 1px.
.demo { border-width: thin; }

medium

A medium line, usually 3px. The default value.
.demo { border-width: medium; }

thick

A thick line, usually 5px.
.demo { border-width: thick; }

2px 8px

Thin on top and bottom, thick on the sides.
.demo { border-width: 2px 8px; }

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • The thin, medium, and thick keywords look slightly different across browsers. Use pixels for precision.
  • Width alone does nothing without border-style.

Related entries

#

Spotted a mistake or missing an example? Write to us.