Here is a way to achieve this:
.container {
width: 200px;
height: 300px;
border: 20px solid transparent; /* adjust line offset */
outline: 3px solid #000; /* modify outline thickness */
outline-offset: -15px; /* adjust rectangle offset */
background:
conic-gradient(from 90deg at 5px 5px,#0000 25%,#000 0)
0 0/calc(100% - 5px) calc(100% - 5px) padding-box border-box;
}
<div class="container"></div>
Using CSS variables for easy customization:
.container {
--c:red; /* color */
--b:2px; /* line thickness */
--o1:20px; /* line offset */
--o2:15px; /* rectangle offset */
width: 200px;
height: 300px;
box-sizing: border-box;
display: inline-block;
border: var(--o1) solid transparent;
outline: var(--b) solid var(--c);
outline-offset: calc(-1*var(--o2));
background:
conic-gradient(from 90deg at var(--b) var(--b),#0000 25%,var(--c) 0)
0 0/calc(100% - var(--b)) calc(100% - var(--b)) padding-box border-box;
}
<div class="container"></div>
<div class="container" style="--c:green;--b:1px;--o1:25px;"></div>
<div class="container" style="--c:blue;--b:4px;--o1:50px;--o2:25px;"></div>
<div class="container" style="--c:#000;--b:1px;--o1:15px;--o2:0;"></div>