CSS Border Generator

Set border width, style and colour for all four sides or each side on its own, see it live, and copy clean CSS.

Preview

How to use the border generator

  1. Pick a width, a style and a colour. The preview box updates as you change anything.
  2. Tick Style each side separately to give the top, right, bottom and left borders their own settings, for example a single bottom border under a heading or a coloured left border on a callout.
  3. Add rounded corners with Border radius, optionally an outline, and copy the CSS.

The output uses the shortest correct form: one border shorthand when all sides match, separate border-top, border-right, border-bottom and border-left rules when they differ.

Border styles

StyleLooks likeTypical use
solidOne continuous lineCards, inputs, dividers
dashedShort dashesDrop zones, "add new" placeholders
dottedRound dotsSubtle separators, focus hints
doubleTwo parallel lines (needs at least 3px)Classic frames, receipts
groove / ridgeCarved or raised 3D edge, shaded from the colourRetro interfaces
inset / outsetBox looks pressed in or outOld-style buttons

Border vs outline vs box-shadow

A border takes up space and changes the element's size unless you use box-sizing: border-box, which is why that option is on by default. An outline is drawn outside the box without affecting layout and is used for focus rings, with outline-offset adding a gap. A box-shadow with zero blur, such as box-shadow: 0 0 0 3px #4f46e5, also draws a line without affecting layout and follows border-radius. For soft shadows use the box shadow generator, and for complex corners the border radius generator.

FAQ

How do I add a border to only one side?

Tick "Style each side separately" and set the other sides' style to none, or write border-bottom: 2px solid #4f46e5; directly.

Why does my double border look solid?

A double border needs room for two lines and a gap, so it only shows at 3px or more.

How do I make a gradient border?

Borders cannot take gradients directly. Use border: 4px solid transparent; background: linear-gradient(#fff, #fff) padding-box, linear-gradient(90deg, #4f46e5, #ec4899) border-box;.