A pixel is the smallest unit value to render something with, but you can trick thickness with optical illusions by modifying colors (the eye can only see up to a certain resolution too).

Here is a test to prove this point:

div { border-color: blue; border-style: solid; margin: 2px; }

div.b1 { border-width: 1px; }
div.b2 { border-width: 0.1em; }
div.b3 { border-width: 0.01em; }
div.b4 { border-width: 1px; border-color: rgb(160,160,255); }
<div class="b1">Some text</div>
<div class="b2">Some text</div>
<div class="b3">Some text</div>
<div class="b4">Some text</div>

Output

Which gives the illusion that the last DIV has a smaller border width, because the blue border blends more with the white background.


Edit: Alternate solution

Alpha values may also be used to simulate the same effect, without the need to calculate and manipulate RGB values.

.container {
  border-style: solid;
  border-width: 1px;
  
  margin-bottom: 10px;
}

.border-100 { border-color: rgba(0,0,255,1); }
.border-75 { border-color: rgba(0,0,255,0.75); }
.border-50 { border-color: rgba(0,0,255,0.5); }
.border-25 { border-color: rgba(0,0,255,0.25); }
<div class="container border-100">Container 1 (alpha = 1)</div>
<div class="container border-75">Container 2 (alpha = 0.75)</div>
<div class="container border-50">Container 3 (alpha = 0.5)</div>
<div class="container border-25">Container 4 (alpha = 0.25)</div>
Answer from Yanick Rochon on Stack Overflow
🌐
W3Schools
w3schools.com › cssref › pr_border-width.php
CSS border-width property
border-width: medium|thin|thick|length|initial|inherit; ... Set the width of the top and bottom borders to 10px, and the width of the left and right borders to 1px: ... If you want to use W3Schools services as an educational institution, team ...
🌐
W3Schools
w3schools.com › css › css_border_width.asp
CSS Border Width
The border-width property specifies the width of the four borders. The width can be set as a specific size (in px, pt, cm, em, etc) or by using one of the three pre-defined values: thin, medium, or thick:
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Reference › Properties › border-width
border-width - CSS | MDN
This property is a shorthand for the following CSS properties: ... /* Keyword values */ border-width: thin; border-width: medium; border-width: thick; /* <length> values */ border-width: 4px; border-width: 1.2rem; /* top and bottom | left and right */ border-width: 2px 1.5em; /* top | left and right | bottom */ border-width: 1px 2em 1.5cm; /* top | right | bottom | left */ border-width: 1px 2em 0 4rem; /* Global values */ border-width: inherit; border-width: initial; border-width: revert; border-width: revert-layer; border-width: unset;
Top answer
1 of 4
248

A pixel is the smallest unit value to render something with, but you can trick thickness with optical illusions by modifying colors (the eye can only see up to a certain resolution too).

Here is a test to prove this point:

div { border-color: blue; border-style: solid; margin: 2px; }

div.b1 { border-width: 1px; }
div.b2 { border-width: 0.1em; }
div.b3 { border-width: 0.01em; }
div.b4 { border-width: 1px; border-color: rgb(160,160,255); }
<div class="b1">Some text</div>
<div class="b2">Some text</div>
<div class="b3">Some text</div>
<div class="b4">Some text</div>

Output

Which gives the illusion that the last DIV has a smaller border width, because the blue border blends more with the white background.


Edit: Alternate solution

Alpha values may also be used to simulate the same effect, without the need to calculate and manipulate RGB values.

.container {
  border-style: solid;
  border-width: 1px;
  
  margin-bottom: 10px;
}

.border-100 { border-color: rgba(0,0,255,1); }
.border-75 { border-color: rgba(0,0,255,0.75); }
.border-50 { border-color: rgba(0,0,255,0.5); }
.border-25 { border-color: rgba(0,0,255,0.25); }
<div class="container border-100">Container 1 (alpha = 1)</div>
<div class="container border-75">Container 2 (alpha = 0.75)</div>
<div class="container border-50">Container 3 (alpha = 0.5)</div>
<div class="container border-25">Container 4 (alpha = 0.25)</div>
2 of 4
6

It's impossible to draw a line on screen that's thinner than one pixel. Try using a more subtle color for the border instead.

🌐
Mimo
mimo.org › glossary › css › border-width
CSS border-width: Customize element borders effortlessly
Learn CSS border-width to define border thickness precisely. Create dynamic designs, highlight elements, and improve layouts with this essential property.
🌐
GeeksforGeeks
geeksforgeeks.org › css › css-border-width-property
CSS Border Width Property %%page%% %%sep%% %%sitename%% - GeeksforGeeks
July 11, 2025 - The border-width: 5px 10px 15px rule sets the top border to 5px, the right and left borders to 10px, and the bottom border to 15px. This creates varying thickness on different sides of the element.
🌐
Programiz
programiz.com › css › border-width
CSS border-width Property (With Examples)
/* styles all p */ p { padding: ... { /* sets the border width to thick */ border-style: thick; } ... We can use the border-width property to change the width of one to all four sides of the border....
🌐
Tailwind CSS
tailwindcss.com › docs › border-width
border-width - Borders - Tailwind CSS
<div class="border-t-4 border-indigo-500 ..."></div><div class="border-r-4 border-indigo-500 ..."></div><div class="border-b-4 border-indigo-500 ..."></div><div class="border-l-4 border-indigo-500 ..."></div>
Find elsewhere
🌐
DoFactory
dofactory.com › css › border-width
CSS border-width
<style> .border-example-multiple { padding: 15px; border-style: solid; border-color: tomato; border-width: thin thick; } </style> <div class="border-example-multiple"> border-width: thin thick </div> Try it live
🌐
TechOnTheNet
techonthenet.com › css › properties › border_width.php
CSS: border-width property
In this CSS border-width example, we have provided four values. The first value of thick would apply to the top of the element. The second value of 10px would apply to the right side of the box. The third value of 12px would apply to the bottom of the box.
Top answer
1 of 10
91

Border doesn't support percentage... but it's still possible...

As others have pointed to CSS specification, percentages aren't supported on borders:

'border-top-width',
'border-right-width',
'border-bottom-width',
'border-left-width'
  Value:          <border-width> | inherit
  Initial:        medium
  Applies to:     all elements
  Inherited:      no
  Percentages:    N/A
  Media:          visual
  Computed value: absolute length; '0' if the border style is 'none' or 'hidden'

As you can see it says Percentages: N/A.

Non-scripted solution

You can simulate your percentage borders with a wrapper element where you would:

  1. set wrapper element's background-color to your desired border colour
  2. set wrapper element's padding in percentages (because they're supported)
  3. set your elements background-color to white (or whatever it needs to be)

This would somehow simulate your percentage borders. Here's an example of an element with 25% width side borders that uses this technique.

HTML used in the example

.faux-borders {
    background-color: #f00;
    padding: 1px 25%; /* set padding to simulate border */
}
.content {
    background-color: #fff;
}
<div class="faux-borders">
    <div class="content">
        This is the element to have percentage borders.
    </div>
</div>

Issue: You have to be aware that this will be much more complicated when your element has some complex background applied to it... Especially if that background is inherited from ancestor DOM hierarchy. But if your UI is simple enough, you can do it this way.

Scripted solution

@BoltClock mentioned scripted solution where you can programmaticaly calculate border width according to element size.

This is such an example with extremely simple script using jQuery.

var el = $(".content");
var w = el.width() / 4 | 0; // calculate & trim decimals
el.css("border-width", "1px " + w + "px");
.content { border: 1px solid #f00; }
<div class="content">
    This is the element to have percentage borders.
</div>

But you have to be aware that you will have to adjust border width every time your container size changes (i.e. browser window resize). My first workaround with wrapper element seems much simpler because it will automatically adjust width in these situations.

The positive side of scripted solution is that it doesn't suffer from background problems mentioned in my previous non-scripted solution.

2 of 10
45

You can also use

border-left: 9vw solid #F5E5D6;
border-right: 9vw solid #F5E5D6;     

OR

border: 9vw solid #F5E5D6;
🌐
Codecademy
codecademy.com › docs › css › borders › border-width
CSS | Borders | border-width | Codecademy
October 21, 2023 - Set the width of the border top to 10px, right and left to medium and bottom to thick: h1 { border-color: green; border-style: dashed; border-width: 10px medium thick; } Copy to clipboard · Copy to clipboard ·
🌐
TutorialsPoint
tutorialspoint.com › css › css_border-width.htm
CSS - border-width Property
<!DOCTYPE html> <html> <head> <style> ... border has a 'thin' border-width. </p> </div> </body> </html> To set a thick width to the borders, we can use the thick value....
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › border
border - CSS | MDN
border = <line-width> || <line-style> || <color> <line-width> = <length [0,∞]> | thin | medium | thick <line-style> = none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
🌐
CSS-Tricks
css-tricks.com › almanac › properties › b › border
border | CSS-Tricks
February 3, 2023 - This is the link https://www.antennahouse.com/hubfs/xsl-fo-sample/block/axf-border-double-thickness-1.pdf?hsLang=en#
🌐
WebPlatform
webplatform.github.io › docs › css › properties › border-width
border-width · WebPlatform Docs
CSS Object Model Property · borderWidth · Percentages · N/A · border-width: <border-top-width> <border-right-width> <border-bottom-width> <border-left-width> border-width: <width> border-width: medium · border-width: thick · border-width: thin · medium · Default.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › border-right-width
border-right-width - CSS | MDN
Nevertheless, they always follow the pattern thin ≤ medium ≤ thick, and the values are constant within a single document. border-right-width = <line-width> <line-width> = <length [0,∞]> | thin | medium | thick
🌐
Littlewebhut
littlewebhut.com › css › border_width
CSS border-width Property
CSS border-width Property - Usage, Examples, and Testing for CSS 2.1.
🌐
W3docs
w3docs.com › learn-css › css-border.html
CSS Border | Border Width | Border Color
The border-width property sets the width of a border. The width can be specified in pixels. It can also be specified by one of the three pre-defined values: medium, thin, or thick.