CSS / Reference / border-style: Border Patterns, Side Order, and Hidden Conflicts
CSS border-style is shorthand for the line style on the top, right, bottom, and left sides of a box. All four sides default to none, so setting only the width and color does not make a border visible. Supply one value for a uniform border or up to four to vary it by side.
Choose a border style
Use solid for a continuous edge. dashed and dotted can help distinguish different edges on the same page. The samples use the same color and width so you can compare the line styles directly.
| Value | Appearance | Preview |
|---|---|---|
solid |
A continuous line | |
dashed |
A series of short line segments | |
dotted |
A series of dots | |
double |
Two parallel lines with a gap |
Four other values use shading. groove makes the border look carved in, while ridge gives it a raised edge. inset makes the area inside the border look sunken, and outset makes it look raised. Dot spacing, dash length, and shading can vary by browser and by border width. See the CSS specification for border styles for the formal definitions.
Map one to four values to the sides
With two values, the first controls top and bottom and the second controls right and left. With three, the order is top, right and left, then bottom. With four, start at the top and read clockwise: top, right, bottom, left.
.same { border-style: solid; }
.axes { border-style: solid dashed; }
.three { border-style: solid dashed double; }
.mixed { border-style: solid dashed double dotted; }
In .three, the top is solid, both sides are dashed, and the bottom is double. To change one side independently, use its longhand, such as border-bottom-style: double. An element does not inherit its parent’s border style by default.
Compare none and hidden in collapsed tables
On an ordinary box, none and hidden both draw no line and give that side a computed border width of zero. With border-collapse set to collapse, adjacent cells share an edge. A neighboring cell’s solid border can still appear when one cell specifies none. If one cell specifies hidden on that edge, it suppresses all competing borders. That precedence comes from the CSS rules for collapsed border conflicts.
To remove just one shared edge, specify hidden on a side that meets it. Use border-collapse: separate if the cells need to keep independent borders.
Verify the result in a browser
Save the entire example as a UTF-8 file named border-style-example.html and open it in a browser. It needs no external stylesheet or library.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Compare CSS border styles</title>
<style>
body { font: 1rem/1.5 system-ui, sans-serif; margin: 1rem; background: #fff; }
main { max-width: 44rem; margin: auto; }
.sample {
box-sizing: border-box;
width: min(100%, 15rem);
padding: 0.7rem;
background: #edf4f8;
border-color: #006c9c;
border-width: 6px;
}
.mixed { border-style: solid dashed double dotted; }
.plain { border-style: none; }
.relief-samples { display: flex; flex-wrap: wrap; gap: .55rem; }
.relief { padding: .55rem; border-width: 10px; border-color: #4d7892; }
.groove { border-style: groove; }
.ridge { border-style: ridge; }
.inset { border-style: inset; }
.outset { border-style: outset; }
table { border-collapse: collapse; margin: 0 0 1rem; }
caption { padding-bottom: .3rem; text-align: start; }
td { padding: .55rem .7rem; background: #f2f5f7; }
.neighbor { border-left: 6px solid #aa3377; }
.none { border-right: 6px none; }
.hidden { border-right: 6px hidden; }
</style>
</head>
<body>
<main>
<h1>Compare CSS border styles</h1>
<h2>Ordinary boxes</h2>
<p class="sample mixed"><code>solid dashed double dotted</code></p>
<p class="sample plain"><code>none</code></p>
<h2>Collapsed tables</h2>
<table>
<caption><code>none</code></caption>
<tr><td class="none">Left cell</td><td class="neighbor">Right cell</td></tr>
</table>
<table>
<caption><code>hidden</code></caption>
<tr><td class="hidden">Left cell</td><td class="neighbor">Right cell</td></tr>
</table>
<h2>Shaded borders</h2>
<div class="relief-samples">
<code class="relief groove">groove</code>
<code class="relief ridge">ridge</code>
<code class="relief inset">inset</code>
<code class="relief outset">outset</code>
</div>
</main>
</body>
</html>
The first box has a solid top, a dashed right edge, a double bottom, and a dotted left edge. The second box uses the same width and color declarations but shows no border because its style is none. Only the none table shows the purple shared line. In the .hidden rule, change the value to none and reload to see the line in both tables. Then restore hidden. In the shaded-border samples, compare the border itself in groove and ridge and the perceived depth of the box in inset and outset.
Find out why a border is missing
Inspect the element in your browser’s developer tools and check the computed border-top-style, border-top-width, and border-top-color. If the style is none, look for a later border shorthand that omits the line style. An omitted style resets to its initial value, none.
.card {
border: 2px #006c9c;
border-bottom-style: solid;
}
The code above draws only the bottom edge. To draw all four edges, replace both declarations with border: 2px solid #006c9c. If the computed style is correct but the line is still missing, check for zero width or a transparent border color. If a double border looks solid, increase its width to around 6px to make the gap easier to see. See border-width for the thickness values you can set on each side.




