CSS border-width Property


The border-width CSS property is used to specify the width of an element's borders. It allows you to control the thickness of each border edge (top, right, bottom, and left) individually or set them all at once with a shorthand notation. You can assign values in various units such as pixels, ems, or percentages to determine the border thickness. For example, border-width: 2px sets all four borders to a thickness of 2 pixels, while border-width: 1px 2px 3px 4px assigns different thickness values clockwise starting from the top border. This property is often used in combination with other border-related properties like border-style and border-color to create custom border styles for elements in web design.

Initial value
See individual properties
Applies to
All elements
Computed value
See individual properties
JavaScript syntax


border-width: <line-width>{1,4} 


<line-width> = <length> | thin | medium | thick
  • thinLess than the default width.
  • mediumDefault value.
  • thickGreater than the default width.
  • <length>Floating-point number, followed by an absolute units designator (cm, mm, in, pt, or pc) or a relative units designator (em, ex, or px).
  • inherit


<div class="border">This is an example of the border-width property using a purple solid border 2px in width.</div>
.border {
   border-style: solid;
   border-width: 2px;
   border-color: purple;
   margin: 20px;
   padding: 20px;

Give it a Try

Click the button below to experiment with this property.

Give it a Try!

Browser Support

The following table will show you the current browser support for the CSS border-width property.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 23rd September 2023