Report

Help us improve this tool

CSS Border Generator

Design CSS borders visually with per side width, style, color, and corner radius controls, then copy the generated CSS instantly.

O M T

What the CSS Border Generator Does

The CSS Border Generator builds border styles visually and writes the CSS for you. Choose a width, style, and color, optionally switch to per side control so each edge can be different, add rounded corners, and watch the live preview update with every change. When the design looks right, copy the generated CSS into your stylesheet.

Everything runs in your browser. There is nothing to install, no upload, and the preview renders the exact CSS you will copy, so what you see is what your page gets.

How to Use the Border Generator

  1. Set the border width, style, and color. The preview updates instantly.
  2. Uncheck Same border on all sides to give the top, right, bottom, and left edges their own width, style, and color.
  3. Adjust the corner radius with the input or the slider to round the corners.
  4. Copy the CSS from the generated code panel, or download it as a CSS file.

The Border Shorthand, Explained

The CSS border shorthand takes three values: width, style, and color. For example, border: 2px solid #3b82f6; draws a two pixel blue solid line around all four sides of an element. The order of the three values is flexible, but width, style, and color is the common convention because it reads naturally.

At least the style is required for a border to appear. If you write only border: 2px red; nothing renders, because the default style is none. That is the single most common reason a border seems to be missing.

Border Styles

  • solid: a single continuous line, the default choice for cards, inputs, and dividers.
  • dashed: evenly spaced dashes, useful for drop zones, tickets, and coupons.
  • dotted: a dotted line, often used for focus rings and decorative edges.
  • double: two parallel lines with a gap, where the width includes both lines and the space between them.
  • groove, ridge, inset, outset: three dimensional effects that simulate carving or embossing by darkening one part of the border. They work best with widths of at least three pixels.
  • none: removes the border entirely, which is useful when overriding a stylesheet.

Per Side Borders

Each edge has its own property: border-top, border-right, border-bottom, and border-left. Per side rules are applied after the shorthand and win when they conflict, which makes a practical pattern: set a base border with the shorthand, then override just the edge you want to change. With this generator you can give every side a different treatment, for example a thick colored bottom edge to create an underline effect, only a left accent bar, or a dashed top with solid sides.

Rounded Corners with border-radius

The corner radius control adds a border-radius rule, rounding all four corners at once. The browser automatically clamps each radius to half the element's width or height, so a very large value turns a square into a circle or a wide element into a pill. For buttons, a radius around 6 to 10 pixels reads as modern and friendly, while fully rounded pills suit call to action buttons and tags.

Practical Uses

  • Card and panel outlines that separate content without heavy shadows.
  • Form input borders that highlight on focus, usually by changing the border color.
  • Dashed drop zones for file upload areas.
  • Ticket and coupon designs with dashed edges and rounded corners.
  • Accent bars and left borders on blockquotes, alerts, and callouts.
  • Debugging layout issues by temporarily outlining every box.

Border vs Outline vs box-shadow

A border is part of the box model, so it adds to the element's size unless you use box-sizing: border-box. An outline is drawn outside the box and never affects layout, which is why it is the standard choice for focus indicators. A box-shadow with a spread radius can simulate a border without affecting layout either, and it follows the border radius. Use a real border when the visual belongs to the element, and an outline or shadow when you need the effect to float above the layout.

Related Tools

Frequently Asked Questions

Why is my border not showing up?

The most common cause is a missing border-style. CSS defaults to border-style: none, so a rule with only a width and color renders nothing. Set a style such as solid or dashed, or check that the width is greater than zero.

How do I make each side different?

Uncheck "Same border on all sides" and set the width, style, and color for the top, right, bottom, and left edges independently. The generated CSS uses the per side properties, which override the shorthand.

Does a border change the size of my element?

Yes, unless the element uses box-sizing: border-box, which is common in modern resets and frameworks. With the default content-box sizing, a 2px border adds 2px to each side of the element's rendered size.

Can I use percentage widths for a border?

No. Percentages are not allowed for border width. Valid values are lengths in px, em, rem, and similar units, plus the keywords thin, medium, and thick, and the value 0 to remove the border.

What is the difference between double and groove?

Double draws two solid parallel lines with a gap between them. Groove uses shading to look carved into the page, and its sibling ridge looks raised. Both grooved styles need a width of at least three pixels to be visible.

Is the generated CSS browser safe?

Yes. Every property generated here is standard CSS supported by all modern browsers, including flexbox based layout tools. No vendor prefixes are required for borders or border-radius.

Can I share a design with a teammate?

Yes. Copy the generated CSS and share it directly, or describe the settings in the tool. The CSS panel includes a download button, so you can save a small border.css file and drop it into any project.