CSS Border Generator

Generate CSS border declarations for uniform borders or side-specific widths, with style, color, unit, and border-radius controls.

Last updated: August 2026 | By Workshelve Team

.box {
  border: 2px solid #0EA5E9;
  border-radius: 8px;
}
Border preview

What CSS Border Controls

CSS borders draw a line around an element's box. The visible result depends on width, style, and color; border-radius separately rounds the corners without changing the border's color or line style.

Use uniform mode when all four sides share the same border. Use individual side mode when one edge needs emphasis, such as a thicker bottom border under a tab or a left accent border beside a callout.

This generator is one-way because border CSS may be split across shorthand properties, side-specific properties, logical properties, variables, and cascade overrides. Generating clean declarations is more dependable than pretending every border can be reversed safely.

How the Border CSS Is Built

1. Width and radius fields are parsed with parseFloat and must be zero or positive.
2. Decimal values are allowed for px, rem, and em, then rounded to four decimal places.
3. Uniform mode emits the border shorthand: width, style, then color.
4. Individual side mode emits border-width in top, right, bottom, left order.
2px solid #0EA5E9
border: 2px solid #0EA5E9;
3.5px dashed #22C55E
border: 3.5px dashed #22C55E;
0px border width
Valid, but no visible line
1rem 4rem 8rem 4rem
top right bottom left

Worked Example: Callout Border

Create a callout with a stronger left and bottom edge:

Widths
top 1px, right 4px, bottom 8px, left 4px
CSS
border-width: 1px 4px 8px 4px;
Order

Four-value border-width follows clockwise CSS shorthand order: top, right, bottom, left.

CSS Border FAQ

Why is this not bidirectional?

Borders can be declared through shorthand, side-specific properties, logical properties, variables, and cascade overrides. A reverse parser would only handle a small subset reliably.

Can border width be zero?

Yes. A zero-width border is valid CSS. It usually produces no visible line, but it can be useful when toggling borders with state classes.

Can border width be negative?

No. CSS border widths and border-radius values cannot be negative, so the generator rejects negative sizing input.

Can I use decimal border values?

Yes. Decimal values such as 1.5px or 0.125rem are valid and useful on high-density screens or token-based design systems.

What does border style none do?

The none style suppresses the visible border even if a width and color are present. It is useful when you need the declaration shape without drawing a line.

Why does individual mode use top right bottom left order?

That is the standard four-value CSS shorthand order for box edges, moving clockwise from the top.

Is border-radius part of the border shorthand?

No. border-radius is a separate property. The border shorthand controls line width, style, and color only.

Why are colors limited to six-digit HEX?

A strict HEX input keeps generated output predictable. CSS supports many other color syntaxes, but this generator keeps the control surface focused.

Related Tools