You may also use box-shadow
and add transparency to that dashed border
via background-clip
to let you see body
background
.
example
h1 {_x000D_
text-align: center;_x000D_
margin: auto;_x000D_
box-shadow: 0 0 0 5px #1761A2;_x000D_
border: dashed 3px #1761A2;_x000D_
background: linear-gradient(#1761A2, #1761A2) no-repeat;_x000D_
background-clip: border-box;_x000D_
font-size: 2.5em;_x000D_
text-shadow: 0 0 2px white, 0 0 2px white, 0 0 2px white, 0 0 2px white, 0 0 2px white;_x000D_
font-size: 2.5em;_x000D_
min-width: 12em;_x000D_
}_x000D_
body {_x000D_
background: linear-gradient(to bottom left, yellow, gray, tomato, purple, lime, yellow, gray, tomato, purple, lime, yellow, gray, tomato, purple, lime);_x000D_
height: 100vh;_x000D_
margin: 0;_x000D_
display: flex;_x000D_
}_x000D_
::first-line {_x000D_
color: white;_x000D_
text-transform: uppercase;_x000D_
font-size: 0.7em;_x000D_
text-shadow: 0 0_x000D_
}_x000D_
code {_x000D_
color: tomato;_x000D_
text-transform: uppercase;_x000D_
text-shadow: 0 0;_x000D_
}_x000D_
em {_x000D_
mix-blend-mode: screen;_x000D_
text-shadow: 0 0 2px white, 0 0 2px white, 0 0 2px white, 0 0 2px white, 0 0 2px white_x000D_
}
_x000D_
<h1>transparent dashed border<br/>_x000D_
<em>with</em> <code>background-clip</code>_x000D_
</h1>
_x000D_