CSS Border Generator
WM-108Set the width, style and color of a border and see it on the preview box. Use one border for all sides or a different one on each side, then copy the CSS.
Runs in your browser. Nothing is uploaded.
Border
Preview and CSS
| border | 4px solid #1f2937 |
|---|
CSS
.box {
border: 4px solid #1f2937;
} How to use it
- Leave Sides on All sides the same, then set the width, style and color.
- Pick a style such as solid, dashed, dotted or double.
- Switch to Each side different to set the top, right, bottom and left separately.
- Press Copy to take the CSS.
One border or four
With all sides the same you get a single border shorthand: width, style and color. With each side different you get border-top, border-right, border-bottom and border-left, which is how you make an underline-only link, a left accent bar or a mixed frame. A side set to style none or width 0 is written as none. In the different mode the single set of fields is ignored.
Border styles to know about
Solid, dashed and dotted are drawn the same in every browser. Double needs a width of at least 3px, because it draws two lines with a gap. Groove, ridge, inset and outset are 3D styles that the browser draws by shading your color, so they can look different between browsers and are used less often today. A border with style none is not drawn at all.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Width must be between 0 and 40. | The border width is outside the supported range. | Enter a width from 0 to 40 pixels. |
Questions people ask
How do I add a border to only one side?
Choose Each side different, give that side a width, style and color, and set the other three to style none or width 0. They are written as none, so only one side is drawn.
Why is my double border showing as a single line?
A double border needs room for two lines and a gap, so the width must be at least 3px. At 1px or 2px the browser draws what looks like a single line.
Does a border change the size of the element?
By default yes: the border is added outside the content and padding. If you want the border counted inside the width and height, set box-sizing: border-box on the element.
What is the difference between border and outline?
A border is part of the box and takes up space. An outline is drawn outside the border and does not change the layout, which is why it is used for keyboard focus rings.
Can I make rounded corners here?
Not in this tool. Use the border radius generator for the corners, then add its border-radius line to the same rule as your border so the border follows the curve.
About this tool
With All sides the same you get one border declaration. With Each side different you get border-top, border-right, border-bottom and border-left, and the single set of fields is ignored. A side with style none or width 0 is written as none. The 3D styles groove, ridge, inset and outset are drawn by the browser by shading your color, so they look different between browsers. The double style needs a width of at least 3px to show two lines. The preview box uses exactly the CSS shown.