CSS border-style Property
Description
The border-style
CSS property is used to define the style of an element's border, determining how it appears visually. It allows you to set various border styles, such as "solid," "dotted," "dashed," "double," "groove," "ridge," and more. Each style creates a different visual effect for the border of an element, allowing web developers to customize the appearance of borders to suit their design requirements. By combining border-style with other border-related properties like border-width and border-color, you can create a wide range of decorative and functional border designs for HTML elements.
- Initial value
- See individual properties
- Applies to
- All elements
- Inherited
- No
- Computed value
- See individual properties
- Animatable
- No
- JavaScript syntax
- object.style.borderStyle
Interactive Demo
Syntax
border-style: <line-style>{1,4}
Values
<line-style> = none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset- noneBorder is not drawn, color and width are ignored. If the border is an image, the image layer counts but is not drawn.
- hiddenSame as none, except in terms of conflict resolution of collapsed borders. Any element with a hidden border suppresses all shared borders at that location. Borders with a style of none have the lowest priority.
- dottedA series of round dots.
- dashedA series of square-ended dashes.
- solidA single line segment.
- doubleTwo parallel solid lines with some space between them.
- grooveDisplays a border leading to a carved effect. It is the opposite of ridge.
- ridgeLooks as if it were coming out of the canvas.
- insetLooks as if the content on the inside of the border is sunken into the canvas.
- outsetLooks as if the content on the inside of the border is coming out of the canvas.
- inherit
Example
<div class="border">This is an example of the border-style property using a purple dashed border 2px in width.</div>
.border {
border-style: dashed;
border-width: 2px;
border-color: purple;
margin: 20px;
padding: 20px;
}
Browser Support
The following table will show you the current browser support for the CSS border-style
property.
Desktop | |||||
12 | 1 | 1 | 3.5 | 1 |
Tablets / Mobile | |||||
18 | 4 | 14 | 3 | 1 | 3 |
Last updated by CSSPortal on: 31st December 2023