CSS BORDER WIDTH

CSS border-width

The border-width property is used to set the thickness of an element's border.

Syntax

selector {
    border-width: value;
}

Example

.box {
    border-width: 5px;
    border-style: solid;
    border-color: black;
}

Here, 5px means the border is 5 pixels thick.

Common Values

border-width: 1px;
border-width: 2px;
border-width: 5px;

You can also use:

border-width: thin;
border-width: medium;
border-width: thick;

Setting Different Widths for Each Side

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

The order is:

Top → Right → Bottom → Left

So:

  • Top = 1px
  • Right = 2px
  • Bottom = 3px
  • Left = 4px

Example with HTML

<div class="box">Hello World</div>
.box {
    border-width: 5px;
    border-style: solid;
    border-color: blue;
}

In simple words: border-width controls how thick the border is.

Comments