CSS Border Generator
Choose a border width, style and colour for the whole box, or switch to different values for each side, then round the corners all at once or one by one. The tool writes the shortest correct CSS, using the single border shorthand when every side matches. It does not draw the box for you, so the guide explains what each style looks like and how the radius shorthand reads.
What you enter
- Different on each side
- Border width
- Border style
- Border colour
- Top width
- Top style
- Top colour
- Right width
- Right style
- Right colour
- Bottom width
- Bottom style
- Bottom colour
- Left width
- Left style
- Left colour
- Corner radius
- Radius
- Top left radius
- Top right radius
- Bottom right radius
- Bottom left radius
- Radius unit
- Add a background colour
- Background colour
How it works
- Set the width, style and colour. Tick Different on each side if the top, right, bottom and left should not match.
- Choose the corner radius in pixels or percent, either one value for all corners or a separate value for each.
- Optionally add a background colour for the box.
- Copy the CSS into the rule for your card, input, image or button.
The eight border styles
Solid is a continuous line and the one you will use most. Dashed is a row of short segments and dotted is a row of round or square dots, depending on the browser. Double draws two thin lines with a gap, and needs a width of at least 3 pixels to show both.
Groove, ridge, inset and outset fake a three-dimensional bevel by drawing the border in two shades of the colour you chose. They look dated on modern flat designs, but they can still be handy for form fields and old-style panels.
Radius and the box model
The border sits between the padding and the margin, and its width counts toward the element's size unless the box-sizing property is set to border-box, which most modern stylesheets do. If your boxes become wider after adding a border, that is why.
Corner radius clips the background and the border to the rounded shape, but it does not clip the content unless you also set overflow to hidden. An image inside a rounded card needs its own radius or the card's overflow hidden, otherwise its square corners poke out.
Tips
- A radius of 50% on a square element makes a circle, which is the standard way to round avatars.
- Use a big pixel radius such as 999px for pill-shaped buttons. It rounds as far as the shape allows and no further, so it works at any height.
- A thick bottom border and thin borders elsewhere is a quick way to make a tab or an underlined heading.
- Double needs at least 3 pixels of width to show two lines, and groove, ridge, inset and outset need a few pixels to look like anything.
- Dotted and dashed borders look best at 1 to 3 pixels. Thicker ones look chunky and may render differently between browsers.
Frequently asked questions
What does the border shorthand contain?
The border property takes a width, a style and a colour, such as 2px solid #4f98fb. Without a style, nothing is drawn, because the default style is none.
How do the four-value shorthands work?
Four values are listed clockwise from the top: top, right, bottom, left. Three values are top, left and right together, bottom. Two values are top and bottom together, then left and right together. One value applies to all four sides. The tool collapses repeats automatically, so 4px 1px 1px 1px is written 4px 1px 1px.
How does border-radius read for each corner?
The four values start at the top left and go clockwise: top left, top right, bottom right, bottom left. With 24px 4px, the top left and bottom right corners get 24px and the other two get 4px.
What is the difference between a pixel and a percent radius?
A pixel radius is a fixed size. A percent radius is relative to the box: 50% means each corner rounds by half the width and half the height, so a square becomes a circle and a rectangle becomes an ellipse.
Why is my border not showing?
The usual causes are a width of zero, a style of none, or a colour that matches the background. Another cause is a rule with a higher specificity elsewhere in your stylesheet overriding it.
Related: CSS shadow generator, CSS layout generator, Hex colour picker.
Start a 7-day free trial or see all free tools. On We.Inc you get a 7-day free trial, not a free plan: card needed, $0 today, cancel before it ends and you pay nothing. AI building is on paid plans from $20 a month.
More in Free Tools
- CSS Button Generator
- CSS Clamp Generator
- CSS Filter Generator
- CSS Formatter
- CSS Gradient Generator
- CSS Grid Generator
- Flexbox and CSS Layout Generator
- CSS Minifier
Related guides
- HTML table borders and zebra rows
- CSS box model: margin vs padding
- CSS triangle generator with border code
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App