CSS Outline & Border Generator

Free toolNo sign-up
Surface:
border
Border on all four sides
outline
Compare to border
Modeborder
Width2px
Sidesuniform
Radius10px

About this generator

Three modes in one tool — Border (per-side controls, 8 styles, alpha-aware color), Outline (layout-neutral, with outline-offset), Gradient border (linear-gradient via background-clip mask, no SVG required). Side-by-side comparison shows border vs outline so you can see WHY one or the other is right for your case.

6 curated presets cover the convergent cases — Soft border, Brand outline, Dashed dropzone, Bottom underline only, Focus outline, Gradient border. 5 framework exports (CSS, SCSS, Tailwind, styled-components, React, Vue).

Permalink: every adjustment encodes into the URL. No login, no watermark, no paywall. Free and MIT-licensed.

Why use this Border Generator?

Border vs outline · side-by-side
Most generators do one or the other. This one shows both with the same values applied so you can SEE the difference: border affects layout, outline does not. Pick the right tool, not the popular one.
Per-side controls
Tabs, dividers, and underlined links need only one or two sides. Toggle to per-side mode and dial each edge independently — no more typing border-bottom: 2px solid #fff manually.
Gradient borders
AI tools usually botch this — they output `border: 2px solid linear-gradient(...)` which is invalid CSS. The generator emits the correct linear-gradient + background-clip recipe that actually works.
Four export formats
CSS, Tailwind utilities, styled-components, SCSS mixin. Switch the export tab to your stack — no manual conversion or copy-and-tweak.

How to use this generator

01
Choose mode
Border is the everyday choice (affects layout). Outline is for focus rings and overlays (sits outside, no layout shift). Gradient produces a colored ring around the element.
02
Switch sides if needed
In border mode, toggle from "All" to "Per-side" to dial each edge independently. Useful for underlined links (bottom only), dividers, table cells.
03
Pick style and color
Eight styles (solid, dashed, dotted, double, groove, ridge, inset, outset) and a full color picker with opacity slider. Dashed is the universal "drop zone" indicator.
04
Compare modes
The side-by-side panel shows your current mode against its opposite (border ↔ outline) with the same values, so the layout impact is visible at a glance.
05
Export to your stack
Switch to CSS, Tailwind, styled-components, or SCSS. Hit Copy or share the URL — every recipe encodes into the query string.

Border & outline reference

PropertyTypical valueWhat it does
border2px solid #7c6cffAffects layout (pushes content via box-sizing). Respects border-radius. Renders inside the element box.
outline2px solid #7c6cffDoes NOT affect layout (sits outside box). Supports outline-offset to push it further out. Used for focus rings.
outline-offset4pxDistance between the element and its outline. Negative values pull the outline inward (overlap the element).
border-radius12pxRounds the corners. Outlines respect it in modern browsers (Safari 16+, Chrome 94+).
border-{side}2px solid …Per-side control. Use border-bottom for underlined links, border-left for blockquote bars, etc.
border-imagelinear-gradient(...) 1Lets you put any image (including gradients) as a border. The legacy way to do gradient borders — bg-clip is more flexible.
border-stylesolid · dashed · dotted · double · groove · ridge · inset · outsetEight built-in patterns. Solid is universal; dashed reads as "drop zone"; double draws two parallel lines.

Common border patterns

Bottom underline link
.link {
  color: #7c6cff;
  text-decoration: none;
  border-bottom: 2px solid currentColor;
  transition: border-color 0.2s;
}
.link:hover { border-color: transparent; }
Dashed file dropzone
.dropzone {
  border: 2px dashed rgba(124, 108, 255, 0.4);
  border-radius: 14px;
  padding: 28px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover, .dropzone.is-dragover {
  border-color: #7c6cff;
  background: rgba(124, 108, 255, 0.06);
}
Gradient border (the correct way)
.gradient-card {
  position: relative;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 22px;
  background:
    linear-gradient(#1a1a24, #1a1a24) padding-box,
    linear-gradient(135deg, #7c6cff, #ec4899) border-box;
  background-clip: padding-box, border-box;
}
Focus ring with offset (a11y)
.button:focus-visible {
  outline: 2px solid #7c6cff;
  outline-offset: 3px;
  border-radius: 8px;
}

Pro tips

01
Outline beats border for focus rings
Borders push surrounding layout when they appear; outlines do not. Always use outline + outline-offset for :focus-visible to avoid jumpy UI on keyboard navigation.
02
Gradient borders need bg-clip
`border: 2px solid linear-gradient(...)` is invalid. The trick: transparent border + two stacked backgrounds (padding-box content + border-box gradient) with background-clip on each.
03
box-sizing affects border math
With box-sizing: border-box (default in modern resets), the border eats into the declared width. With content-box, the border ADDS to the width. Pick one and stick with it.
04
Mind border collapse on tables
Table cells with their own borders need `border-collapse: collapse` on the parent or you get doubled lines. SVG borders avoid this entirely.
?

Frequently asked questions

01

What's the actual difference between border and outline?

Three things. (1) Layout — border occupies space inside the element's box; outline does NOT — it's painted outside the box without shifting surrounding content. (2) Radius — border respects border-radius (curves around rounded corners); outline historically did NOT but as of 2022+ outline DOES follow border-radius in Chrome 94+, Firefox 88+, Safari 16.4+. (3) Offset — outline supports outline-offset (positive = gap, negative = inset); border has no equivalent. Use border for visual structure that affects layout. Use outline for focus rings, debug overlays, and any indicator that should NOT shift content.

02

How does the gradient-border trick work?

CSS doesn't ship a native gradient-border property. The workaround uses linear-gradient as the BACKGROUND in border-box clipping mode, with a transparent border on top, and a second layer of solid background in padding-box clipping mode to mask the inner area. The generator emits the full recipe — copy-paste ready. Modern alternative: border-image with a linear-gradient source — works but has more quirks (doesn't combine with border-radius cleanly). The mask-based recipe in this generator's gradient mode is the most production-tested pattern.

03

Why per-side borders?

Two common cases: (1) bottom-only underline borders for nav links and form labels — Material Design's text input is just border-bottom: 1px solid. (2) Asymmetric card decorations — a thick left border that signals 'callout' (used by Linear, Stripe docs, GitHub issue threads). Per-side mode in this generator emits border-top / border-right / border-bottom / border-left separately so only the sides you set get rendered.

04

Should I use outline or box-shadow for focus rings?

outline is the right answer for accessibility focus rings — it doesn't affect layout (vs box-shadow which can affect layout via element re-flow in some edge cases), it has the dedicated outline-offset property for the gap between the element and the ring, and it's the property modern accessibility tools (axe-core, Lighthouse) check for keyboard focus. WCAG 2.2 1.4.11 (Non-text Contrast) requires focus indicators have ≥3:1 contrast against adjacent colors. Use outline: 2px solid + outline-offset: 2px and you've satisfied the requirement.

05

Does the dashed/dotted pattern look the same in all browsers?

Mostly. The actual dash + gap lengths are browser-defined and can vary slightly — Chrome / Edge use one pattern, Safari uses a slightly different one, Firefox uses a third. For pixel-perfect cross-browser dashes, use border-image with a custom SVG instead. For 95% of UI, the native dashed style is fine — designers rarely notice the difference between Chrome and Safari dash patterns.

06

Is this free for commercial use?

Free, MIT-licensed, zero attribution required, no watermark, no signup. Use on any project — personal, client, enterprise — without permission.

See it used in real designs

Browse hand-coded collections that put this tool to work.

Search CodeFronts

Loading…