CSS Reference ยท Borders, Outlines and Shadows
The border-style property
Reference for the CSS border-style property: solid, dashed, dotted, double, groove, ridge, inset, outset, none and hidden, with one to four values.
The border-style property chooses the line pattern of an element's borders: solid, dashed, dotted and so on. It is a shorthand for the four side properties (border-top-style and the rest) and takes one to four values.
It is also the property that switches borders on. The initial value is none, so a border has no visible line, and no width, until you set a different style.
.box { border-style: solid dashed; }
Try it
The boxes with none and hidden have no visible border even though a width and color are set.
Syntax
border-style: <line-style>{1,4} /* <line-style> = none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset */
- Initial value:
none - Applies to: all elements
- Inherited: no
- Animatable: no (discrete)
- Computed value: as specified
Values
| Value | Description |
|---|---|
none |
No border. The computed border width becomes 0. In a collapsed table, it loses against any other style. |
hidden |
Like none, but in a collapsed table border it wins over every other conflicting border, which removes the line completely. |
solid |
A single continuous line. |
dashed |
A series of short dashes. |
dotted |
A series of round or square dots. |
double |
Two lines with a gap; the two lines and the gap together equal the border width. Needs a width of at least 3px to show both lines. |
groove |
A carved look: the border appears sunken into the page. |
ridge |
The opposite of groove: the border appears raised. |
inset |
The whole box looks pressed into the page. |
outset |
The whole box looks raised from the page. |
| One to four values | Same pattern as margin: all, vertical + horizontal, top + horizontal + bottom, or top, right, bottom, left. |
Usage notes
- Remember it is off by default. Many "my border does not show" bugs are a missing style.
border: 1px solidis the safe form. - 3D styles use shades of the color.
groove,ridge,insetandoutsetdraw lighter and darker variations ofborder-color. The exact shades differ between browsers, and the look is dated, so most modern designs usesolid. dashedanddottedspacing is browser-dependent. The dash lengths are not specified exactly. If you need precise dashes, use an SVG or a gradient background.- Corners. Where two sides have different styles, the corner is split along a diagonal.
hiddenvsnonematter in tables. Outside collapsed tables they behave the same. Seeborder-collapse.- Accessibility. Borders are a good way to mark control boundaries, especially in forced colors mode where backgrounds disappear. Do not remove all borders from inputs and buttons without another visible cue.
Browser support
Supported in every browser.
Related
borderโ the shorthandborder-widthโ thicknessborder-colorโ coloroutline-styleโ the outline equivalent- Lessons: Borders, Tables