2023 - singleSingle element, no pseudo elements, no SVG, no masks.
I can't take credit for this, I saw this on a website (I forgot the site and can't find it again).
- It's just a normal
buttonwith rounded edges and a gradient background - It uses a
box-shadowthat isinsetto fill the inside with white - It has a 2px border which is actually transparent, so the very edge of the button shows through
body { background: aliceblue; } .gradient-border { border-radius: 24px; padding: 6px 12px; background-image: linear-gradient(90deg, red 0%, blue 100%); /* Fill the inside with white */ background-origin: border-box; box-shadow: inset 0 100vw white; /* A transparent border, so the very edge of the button shows through */ border: 2px solid transparent; } <button class="gradient-border">Hello</button>