CSS border-width Property

The border-width shorthand property sets the thickness of an element's top, right, bottom, and left borders.

It accepts one to four values, using the keywords thin, medium, and thick, or non-negative CSS lengths such as 2px, 0.25rem, and 0.3em.

The property controls border thickness only. A visible border style, such as solid, dashed, or dotted, is required for a border to appear.

border-width Syntax

Specify one to four width values to control the thickness of an element's borders.

selector {
  border-width: 4px;
}

The general syntax is:

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

One Value

.panel {
  border-width: 4px;
}

All four borders receive the same width.

Two Values

.panel {
  border-width: 4px 8px;
}

The first value applies to the top and bottom borders. The second applies to the right and left borders.

Three Values

.panel {
  border-width: 4px 8px 2px;
}

The values apply to the top, right and left, and bottom borders.

Four Values

.panel {
  border-width: 4px 8px 2px 6px;
}

The values apply clockwise: top, right, bottom, and left.

Keyword Widths

.panel {
  border-width: thin medium thick;
}

Mixed Width Values

.panel {
  border-width: thin 4px 0.5rem thick;
}

CSS-Wide Keywords

.inherited {
  border-width: inherit;
}
.reset {
  border-width: initial;
}
.unset {
  border-width: unset;
}
.reverted {
  border-width: revert;
}
.layer-reverted {
  border-width: revert-layer;
}

CSS-wide keywords must be used alone. They cannot be mixed with individual width values in the same declaration.

Property Values

The border-width shorthand accepts three predefined width keywords or non-negative CSS lengths.

Value Description
thin Specifies a thin border. The exact thickness is determined by the browser.
medium Specifies a medium-width border. This is the initial value of each border-width longhand.
thick Specifies a thick border. The exact thickness is determined by the browser.
<length> Specifies a non-negative border width using a CSS length such as px, rem, or em.
0 Sets the affected border widths to zero.

CSS-Wide Keywords

Value Description
inherit Inherits all four computed border widths from the parent element.
initial Resets all four specified border widths to medium.
unset Resets all four specified border widths to medium because the longhand properties are not inherited.
revert Reverts the four border widths according to cascade origin rules.
revert-layer Reverts the four border widths according to cascade layer rules.

Property Characteristics

Characteristic Value
Initial value medium for each longhand
Inherited No
Applies to All elements
Computed value Absolute length for each side, or zero when that side's border style is none or hidden
Animation type By computed value type for each longhand
Property type Shorthand
Number of values One to four
Percentages Not accepted

The border-width shorthand sets all four physical border-width longhands. It does not set border styles or colors.

How It Works

The browser expands the border-width shorthand into four individual border widths.

Step 1: Create an Element

<div class="panel">
  This panel has custom border widths.
</div>

Step 2: Add Basic Styling

.panel {
  padding: 24px;
  background-color: #f3f7fa;
}

Step 3: Add a Visible Border Style

.panel {
  border-style: solid;
}

All four borders become visible using their initial medium widths and the current text color unless other declarations override them.

Step 4: Set All Border Widths

.panel {
  border-width: 4px;
}

All four borders become 4 pixels thick.

Step 5: Set Different Widths

.panel {
  border-width: 8px 4px 2px 6px;
}

The top border becomes 8 pixels, the right border 4 pixels, the bottom border 2 pixels, and the left border 6 pixels.

Step 6: Set the Border Color

.panel {
  border-color: #1769aa;
}

Step 7: Remove All Border Widths

.panel {
  border-width: 0;
}

All four borders have zero thickness and are not visible.

The shorthand makes it possible to control all four physical border widths with a single declaration.

One to Four Values

The number of values determines how the border widths are distributed around the element.

One Value: All Sides

.panel {
  border-style: solid;
  border-width: 5px;
}

Equivalent longhand declarations:

.panel {
  border-top-width: 5px;
  border-right-width: 5px;
  border-bottom-width: 5px;
  border-left-width: 5px;
}

Two Values: Vertical and Horizontal

.panel {
  border-style: solid;
  border-width: 8px 3px;
}

Equivalent longhand declarations:

.panel {
  border-top-width: 8px;
  border-right-width: 3px;
  border-bottom-width: 8px;
  border-left-width: 3px;
}

Three Values: Top, Sides, Bottom

.panel {
  border-style: solid;
  border-width: 8px 3px 2px;
}

Equivalent longhand declarations:

.panel {
  border-top-width: 8px;
  border-right-width: 3px;
  border-bottom-width: 2px;
  border-left-width: 3px;
}

Four Values: Clockwise

.panel {
  border-style: solid;
  border-width: 8px 4px 2px 6px;
}

Equivalent longhand declarations:

.panel {
  border-top-width: 8px;
  border-right-width: 4px;
  border-bottom-width: 2px;
  border-left-width: 6px;
}

Value Distribution Table

Values Top Right Bottom Left
4px 4px 4px 4px 4px
4px 8px 4px 8px 4px 8px
4px 8px 2px 4px 8px 2px 8px
4px 8px 2px 6px 4px 8px 2px 6px

The four-value order follows the physical sides clockwise: top, right, bottom, and left.

Keyword Widths

The thin, medium, and thick keywords provide browser-defined border thicknesses.

thin

.panel {
  border-style: solid;
  border-width: thin;
}

medium

.panel {
  border-style: solid;
  border-width: medium;
}

thick

.panel {
  border-style: solid;
  border-width: thick;
}

Different Keyword Widths

.panel {
  border-style: solid;
  border-width: thin medium thick;
}

The top border uses thin, the right and left borders use medium, and the bottom border uses thick.

Mixing Keywords and Lengths

.panel {
  border-style: solid;
  border-width: thin 4px thick 0.5rem;
}

Keyword widths can be combined with explicit length values in the same declaration.

Keyword Measurements

The specification does not assign fixed pixel measurements to these keywords. Browsers choose the actual thicknesses while preserving their relative order.

Use explicit lengths when precise, consistent border thickness is important.

Length Values

The border-width property supports non-negative CSS length values for each side.

Pixels

.panel {
  border-width: 4px;
}

Pixels provide a specific CSS pixel measurement.

rem Units

.panel {
  border-width: 0.25rem;
}

The width is based on the root element's font size.

em Units

.panel {
  border-width: 0.3em;
}

The width is based on the element's font size.

Viewport Units

.panel {
  border-width: 0.4vw;
}

The border width scales with the viewport width.

Calculated Width

.panel {
  border-width: calc(2px + 0.2rem);
}

Clamped Width

.panel {
  border-width: clamp(2px, 0.5vw, 8px);
}

The clamp() function provides a preferred responsive width with minimum and maximum limits.

Different Length Units

.panel {
  border-width: 4px 0.25rem 0.3em 6px;
}

Fractional Widths

.panel {
  border-width: 0.5px;
}

Fractional CSS pixel widths are valid. Their rendered appearance depends on device resolution and browser rasterization.

For most interface designs, pixels and rem units provide predictable results.

Zero and Invalid Values

Zero is valid for border widths, but negative lengths, percentages, and unsupported units are not.

Zero Width on All Sides

.panel {
  border-style: solid;
  border-width: 0;
}

All four borders have zero thickness.

Zero Width on Selected Sides

.panel {
  border-style: solid;
  border-width: 0 4px;
}

The top and bottom borders have zero width. The left and right borders are 4 pixels thick.

Negative Width

.panel {
  border-width: -4px;
}

This declaration is invalid because negative border widths are not allowed.

Percentage Width

.panel {
  border-width: 10%;
}

This declaration is invalid because percentages are not supported.

Too Many Values

.panel {
  border-width: 1px 2px 3px 4px 5px;
}

This declaration is invalid because the shorthand accepts no more than four values.

Missing Units

.panel {
  border-width: 4;
}

This declaration is invalid because nonzero CSS lengths require units.

Calculated Negative Width

.panel {
  border-width: calc(2px - 10px);
}

A calculated width that resolves to a negative value is clamped to zero rather than producing a negative border thickness.

Valid Unitless Zero

.panel {
  border-width: 0;
}

Zero does not require a unit.

When one value in a shorthand declaration is invalid, the entire declaration is invalid.

Border Style and Color

The border-width property controls thickness only. The border style and color are separate components.

Width Without a Visible Style

.panel {
  border-width: 6px;
}

If all border styles remain none, no borders appear and their computed widths are zero.

Adding a Visible Style

.panel {
  border-style: solid;
  border-width: 6px;
}

Setting the Color

.panel {
  border-style: solid;
  border-width: 6px;
  border-color: #1769aa;
}

Different Border Styles

.panel {
  border-style: solid dashed dotted double;
  border-width: 4px 6px 8px 10px;
  border-color: #1769aa;
}

Using currentColor

.panel {
  color: #1769aa;
  border-style: solid;
  border-width: 4px;
  border-color: currentColor;
}

All four borders use the element's computed text color.

Transparent Borders

.panel {
  border-style: solid;
  border-width: 6px;
  border-color: transparent;
}

The borders are transparent but still contribute to the box model.

Hidden and None Styles

.panel {
  border-style: none;
  border-width: 10px;
}

When a side's style is none or hidden, its computed border width is zero regardless of the width specified.

Use border-style, border-width, and border-color together for explicit control over all border components.

Shorthand and Longhand Properties

The border-width property sets four physical border-width longhands.

Individual Width Properties

.panel {
  border-top-width: 8px;
  border-right-width: 4px;
  border-bottom-width: 2px;
  border-left-width: 6px;
}

Equivalent border-width Shorthand

.panel {
  border-width: 8px 4px 2px 6px;
}

border Shorthand

.panel {
  border: 4px solid #1769aa;
}

The border shorthand sets the width, style, and color of all four borders.

Individual Side Shorthand

.panel {
  border-top: 8px solid #1769aa;
}

This shorthand sets the width, style, and color of the top border only.

Overriding One Side

.panel {
  border: 4px solid #1769aa;
  border-top-width: 10px;
}

The top border becomes 10 pixels thick while the other sides remain 4 pixels thick.

Shorthand Override

.panel {
  border-top-width: 10px;
  border-width: 4px;
}

The later shorthand resets all four border widths to 4 pixels.

Longhand Override

.panel {
  border-width: 4px;
  border-top-width: 10px;
}

The later longhand changes only the top border width.

Omitted Width in the border Shorthand

.panel {
  border-width: 8px;
  border: solid #1769aa;
}

The later border shorthand resets the omitted width components to their initial value, medium.

Use the shorthand for consistent widths across multiple sides and the longhands for individual adjustments.

Physical vs. Logical Borders

The border-width shorthand sets physical border widths. The order always follows the top, right, bottom, and left edges.

Logical border properties follow the element's writing mode and direction.

Physical Border Widths

.panel {
  border-width: 8px 4px 2px 6px;
}

Logical Block Border Widths

.panel {
  border-block-width: 8px 2px;
}

The first value applies to the block-start edge, and the second applies to the block-end edge.

Logical Inline Border Widths

.panel {
  border-inline-width: 6px 4px;
}

The first value applies to the inline-start edge, and the second applies to the inline-end edge.

Horizontal Writing Mode

.panel {
  writing-mode: horizontal-tb;
  border-block-width: 8px 2px;
  border-inline-width: 6px 4px;
}

With left-to-right direction, block-start is the physical top, block-end is bottom, inline-start is left, and inline-end is right.

Vertical Writing Mode

.panel {
  writing-mode: vertical-rl;
  border-block-width: 8px 2px;
  border-inline-width: 6px 4px;
}

In vertical right-to-left writing mode, block-start corresponds to the physical right edge and block-end to the left edge.

Physical and Logical Overrides

.panel {
  writing-mode: horizontal-tb;
  border-style: solid;
  border-width: 4px;
  border-block-start-width: 10px;
}

The later logical declaration changes the physical top border width in this writing mode when cascade priority is otherwise equal.

Use physical properties for fixed edge placement and logical properties when borders should follow writing mode and text direction.

Box Model and Layout

Border widths contribute to an element's total dimensions according to the CSS box model.

content-box Sizing

.panel {
  box-sizing: content-box;
  width: 300px;
  height: 100px;
  padding: 20px;
  border: 5px solid #1769aa;
}

The specified width and height apply to the content box. Padding and borders are added outside those dimensions.

The total outer width is 350 pixels, and the total outer height is 150 pixels, excluding margins.

border-box Sizing

.panel {
  box-sizing: border-box;
  width: 300px;
  height: 150px;
  padding: 20px;
  border: 5px solid #1769aa;
}

The declared width and height include the content, padding, and borders.

Different Border Widths

.panel {
  box-sizing: content-box;
  width: 300px;
  padding: 20px;
  border-style: solid;
  border-width: 8px 4px 2px 6px;
}

The left and right borders add a combined 10 pixels to the element's outer width. The top and bottom borders add a combined 10 pixels to its outer height.

Preventing Layout Shifts

.button {
  border: 3px solid transparent;
}
.button:hover {
  border-color: #1769aa;
}

Keeping the border width constant prevents the border from being added only during hover.

Using an Inset Box Shadow

.panel {
  box-shadow: inset 0 0 0 5px #1769aa;
}

An inset box shadow can simulate a border without contributing to the element's box dimensions.

When exact dimensions matter, account for border thickness or use box-sizing: border-box to simplify sizing.

Border Width and Rounded Corners

Border widths can be combined with border-radius to create rounded corners.

Rounded Border

.panel {
  border: 5px solid #1769aa;
  border-radius: 12px;
}

Different Border Widths

.panel {
  border-style: solid;
  border-color: #1769aa;
  border-width: 8px 4px 2px 6px;
  border-radius: 16px;
}

The browser adjusts the border's inner and outer curves according to the border widths and corner radii.

Thick Rounded Border

.panel {
  border: 12px solid #1769aa;
  border-radius: 24px;
}

Pill-Shaped Element

.pill {
  display: inline-block;
  padding: 10px 24px;
  border: 3px solid #1769aa;
  border-radius: 999px;
}

Rounded Border with Transparent Color

.panel {
  border: 6px solid transparent;
  border-radius: 16px;
  background-color: #e7f3fc;
}

Transparent borders still contribute to the box model and participate in the rounded border geometry.

Thick borders can make corner shapes more noticeable, especially when different widths are applied to adjacent sides.

Table Borders

Border widths interact with the table border model, particularly when border-collapse: collapse is used.

Separate Table Borders

table {
  border-collapse: separate;
}
td {
  border: 3px solid #1769aa;
}

Each table cell draws its own borders independently.

Collapsed Table Borders

table {
  border-collapse: collapse;
}
td {
  border: 2px solid #777777;
}

Adjacent cell borders share an edge, and the browser resolves competing border declarations.

Different Border Widths

table {
  border-collapse: collapse;
}
td {
  border: 2px solid #777777;
}
td.highlight {
  border-width: 6px;
}

When competing collapsed borders have compatible styles and no higher-priority conflict rule applies, the thicker border generally wins.

Hidden Borders

td.hidden-border {
  border-style: hidden;
  border-width: 10px;
}

The hidden style suppresses competing collapsed borders, regardless of the specified width.

None Borders

td.no-border {
  border-style: none;
  border-width: 10px;
}

The computed border widths become zero when the corresponding styles are none.

For predictable table layouts, use consistent border styles and widths unless a particular cell or row requires emphasis.

Cascade and Overrides

The CSS cascade determines which border widths apply when multiple declarations target the same element.

Later Declaration

.panel {
  border-width: 4px;
  border-width: 8px;
}

The later declaration wins when cascade priority is otherwise equal.

Higher Specificity

.panel {
  border-width: 4px;
}
.panel.featured {
  border-width: 8px;
}

Longhand Override

.panel {
  border-width: 4px;
  border-top-width: 10px;
}

The top border becomes 10 pixels thick while the other sides remain 4 pixels thick.

Shorthand Override

.panel {
  border-top-width: 10px;
  border-width: 4px;
}

The later shorthand resets all four border widths to 4 pixels.

CSS Layers

@layer base, components;
@layer base {
  .panel {
    border-width: 2px;
  }
}
@layer components {
  .panel {
    border-width: 6px;
  }
}

For normal declarations, the later layer takes precedence.

Resetting All Widths

.panel {
  border-width: 8px;
}
.panel.no-border {
  border-width: 0;
}

Resetting to Initial Values

.panel {
  border-width: 8px;
}
.panel.reset {
  border-width: initial;
}

The specified widths return to medium. The computed width of any side with none or hidden style remains zero.

When troubleshooting border widths, inspect declarations involving border-width, individual border-width properties, and the border shorthand.

CSS Custom Properties

Custom properties can store reusable border widths and make component variations easier to maintain.

Shared Border Width

:root {
  --border-width: 4px;
}
.panel {
  border-style: solid;
  border-width: var(--border-width);
}

Fallback Width

.panel {
  border-style: solid;
  border-width: var(--border-width, 3px);
}

Component Variants

.card {
  --border-width: 3px;
  border-style: solid;
  border-color: #1769aa;
  border-width: var(--border-width);
}
.card.featured {
  --border-width: 8px;
}
.card.compact {
  --border-width: 1px;
}

Different Side Variables

:root {
  --border-top: 8px;
  --border-right: 4px;
  --border-bottom: 2px;
  --border-left: 6px;
}
.panel {
  border-style: solid;
  border-width: var(--border-top) var(--border-right) var(--border-bottom) var(--border-left);
}

Calculated Custom Property

:root {
  --base-border-width: 2px;
}
.panel {
  border-style: solid;
  border-width: calc(var(--base-border-width) * 3);
}

Responsive Custom Property

.panel {
  --border-width: 6px;
  border: var(--border-width) solid #1769aa;
}
@media (max-width: 600px) {
  .panel {
    --border-width: 3px;
  }
}

Custom properties help maintain consistent border thickness across related components and responsive layouts.

Transitions and Animation

The border-width shorthand can animate changes to its four border-width longhands.

Hover Width Transition

.panel {
  border: 2px solid #1769aa;
  transition: border-width 0.3s ease;
}
.panel:hover {
  border-width: 8px;
}

Different Side Transitions

.panel {
  border: 2px solid #1769aa;
  transition: border-width 0.3s ease;
}
.panel:hover {
  border-width: 8px 4px 2px 6px;
}

Selected State

.card {
  border: 3px solid #1769aa;
  transition: border-width 0.3s ease;
}
.card.is-selected {
  border-width: 8px;
}

Keyframe Animation

@keyframes border-grow {
  0%, 100% {
    border-width: 2px;
  }
  50% {
    border-width: 10px;
  }
}
.animated-panel {
  border-style: solid;
  border-color: #1769aa;
  animation: border-grow 3s ease-in-out infinite;
}

Width and Color Transition

.panel {
  border: 2px solid #1769aa;
  transition: border-width 0.3s ease, border-color 0.3s ease;
}
.panel:hover {
  border-width: 8px;
  border-color: #c04b37;
}

Inset Shadow Alternative

.panel {
  box-shadow: inset 0 0 0 2px #1769aa;
  transition: box-shadow 0.3s ease;
}
.panel:hover {
  box-shadow: inset 0 0 0 8px #1769aa;
}

An inset box shadow can simulate a thicker border without changing the element's box dimensions.

Reduced Motion Preference

.panel {
  border: 2px solid #1769aa;
  transition: border-width 0.3s ease;
}
.panel:hover {
  border-width: 8px;
}
@media (prefers-reduced-motion: reduce) {
  .panel {
    transition: none;
  }
}

Animating border widths can affect layout. For purely decorative effects, consider a box shadow or positioned pseudo-element.

Responsive Design

Border widths can adapt to viewport width, container size, and component dimensions.

Media Query

.panel {
  border: 8px solid #1769aa;
}
@media (max-width: 600px) {
  .panel {
    border-width: 3px;
  }
}

Container Query

.panel-container {
  container-type: inline-size;
}
.panel {
  border: 3px solid #1769aa;
}
@container (min-width: 500px) {
  .panel {
    border-width: 8px;
  }
}

Fluid Border Width

.panel {
  border-style: solid;
  border-color: #1769aa;
  border-width: clamp(2px, 0.5vw, 8px);
}

Responsive Side Widths

.panel {
  border-style: solid;
  border-color: #1769aa;
  border-width: 8px 4px;
}
@media (max-width: 600px) {
  .panel {
    border-width: 4px 2px;
  }
}

Removing Borders on Small Screens

.panel {
  border: 6px solid #1769aa;
}
@media (max-width: 480px) {
  .panel {
    border-width: 0;
  }
}

Logical Border Alternative

.panel {
  border-block-width: 6px 2px;
  border-inline-width: 4px;
  border-style: solid;
  border-color: #1769aa;
}

Logical border properties can adapt to writing modes, while border-width always follows physical sides.

Responsive border widths can help maintain visual balance across different screen and component sizes.

Practical Uses

The border-width property is useful for cards, panels, buttons, navigation elements, and decorative borders.

Uniform Card Border

.card {
  padding: 24px;
  border: 2px solid #1769aa;
}

Thick Top and Bottom Borders

.panel {
  border-style: solid;
  border-color: #1769aa;
  border-width: 8px 2px;
}

Featured Card

.featured-card {
  padding: 24px;
  border-style: solid;
  border-color: #1769aa;
  border-width: 8px 2px 2px;
}

Asymmetric Border

.accent-panel {
  padding: 20px;
  border-style: solid;
  border-color: #1769aa;
  border-width: 2px 2px 2px 10px;
}

Outlined Button

.outline-button {
  padding: 10px 20px;
  border: 2px solid #1769aa;
  background-color: transparent;
  color: #1769aa;
}

Double Border

.decorative-panel {
  padding: 20px;
  border: 8px double #1769aa;
}

Notification Panel

.notification {
  padding: 20px;
  background-color: #fff8e8;
  border-style: solid;
  border-color: #b7791f;
  border-width: 6px 1px 1px;
}

Card Variants

.card {
  border: 2px solid #1769aa;
}
.card.featured {
  border-width: 6px;
}
.card.compact {
  border-width: 1px;
}

Use border thickness to establish visual hierarchy, but avoid relying on thickness alone to communicate important information.

border-width Example

The following example demonstrates how one, two, three, and four width values affect an element's borders.

<div class="border-width-demo">
  <div class="demo-box one">4px</div>
  <div class="demo-box two">8px 3px</div>
  <div class="demo-box three">8px 3px 2px</div>
  <div class="demo-box four">8px 4px 2px 6px</div>
  <div class="demo-box keywords">thin medium thick</div>
  <div class="demo-box mixed">thin 4px thick 0.5rem</div>
</div>
.border-width-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
}
.border-width-demo .demo-box {
  box-sizing: border-box;
  min-height: 110px;
  padding: 20px;
  border-style: solid;
  border-color: #1769aa;
  background-color: #e7f3fc;
  color: #173b5e;
  font-weight: bold;
  text-align: center;
}
.border-width-demo .one {
  border-width: 4px;
}
.border-width-demo .two {
  border-width: 8px 3px;
}
.border-width-demo .three {
  border-width: 8px 3px 2px;
}
.border-width-demo .four {
  border-width: 8px 4px 2px 6px;
}
.border-width-demo .keywords {
  border-width: thin medium thick;
}
.border-width-demo .mixed {
  border-width: thin 4px thick 0.5rem;
}
Browser Result
4px
8px 3px
8px 3px 2px
8px 4px 2px 6px
thin medium thick
thin 4px thick 0.5rem

The first four examples demonstrate the shorthand's value distribution. The final two examples show keyword widths and a combination of keywords and length values.

Keyword thicknesses may vary between browsers, while explicit CSS lengths provide more predictable measurements.

Important Considerations

Keep the following points in mind when using border-width:

  • Purpose: Controls the thickness of all four physical borders.
  • Property type: Shorthand for four border-width longhands.
  • Initial values: medium for each longhand.
  • Inheritance: The longhand properties are not inherited.
  • Accepted values: thin, medium, thick, or non-negative CSS lengths.
  • Value count: Accepts one to four values.
  • Value order: Four values apply clockwise: top, right, bottom, and left.
  • Percentages: Not supported.
  • Negative lengths: Invalid.
  • Zero width: Removes the visible thickness of the affected borders.
  • Visible style: A style other than none or hidden is required for a border to appear.
  • Computed widths: A side's computed width becomes zero when its border style is none or hidden.
  • Keyword measurements: Exact thicknesses are browser-defined.
  • Physical sides: Always targets top, right, bottom, and left regardless of writing mode.
  • Logical alternatives: Use border-block-width and border-inline-width when widths should follow writing mode.
  • Shorthand interactions: Later border declarations may reset the widths.
  • Box model: Border thickness contributes to element dimensions according to box-sizing.
  • Layout changes: Increasing border widths can affect layout and cause content movement.
  • Animation: Compatible border-width values can interpolate smoothly.
  • Browser support: The property is widely supported.

Use border-width when you need to set multiple border thicknesses efficiently without changing their styles or colors.

Browser Support

The border-width property is widely available and supported in Chrome, Edge, Firefox, Safari, and other major browsers.

Modern browsers support one to four width values, predefined width keywords, and non-negative CSS lengths without vendor prefixes.

.panel {
  border-style: solid;
  border-width: 8px 4px 2px 6px;
  border-color: #1769aa;
}

This declaration creates borders with different thicknesses on all four sides.

For current compatibility details, visit Can I Use? and search for border-width.

Specifications

The border-width property is defined in the CSS Backgrounds and Borders Module Level 3 specification.

CSS Backgrounds and Borders Module Level 3

The specification defines the shorthand syntax, accepted width values, computed border widths, and interactions with border styles.