CSS border-style Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Box Model & Borders

What You’ll Learn

The border-style property defines how the border lines look on an element. It controls whether borders are solid, dashed, dotted, double, or one of several 3D-style effects.

01

All Sides

Top, right, bottom, left.

02

solid

Continuous line.

03

dashed / dotted

Soft dividers.

04

3D Styles

groove, ridge, inset.

05

none Default

No border by default.

06

Shorthand

One to four values.

Definition and Usage

The border-style CSS property defines the style of the border around an element. It controls the appearance of all four sides and is essential for adding visual structure and emphasis to boxes, cards, and layout components.

By choosing different border styles such as solid, dashed, or dotted, you can create a variety of effects for cards, form fields, callouts, and decorative UI elements.

💡
Beginner Tip

A border only appears when border-style is not none. Pair it with border-width and border-color, or use border: 2px solid #000; as shorthand.

📝 Syntax

The syntax for border-style is straightforward:

syntax.css
selector {
  border-style: <border-style>;
}

Basic Example

border-style.css
p {
  border-style: solid;
  border-width: 2px;
  border-color: #000;
}

The style value refers to the border line type, such as solid, dashed, or dotted.

Syntax Rules

  • The initial value is none, which hides the border.
  • One value applies to all four sides; up to four values target top, right, bottom, and left.
  • Common values include solid, dashed, and dotted.
  • 3D-style keywords include groove, ridge, inset, and outset.
  • Pair with border-width and border-color, or use the border shorthand.

⚡ Quick Reference

QuestionAnswer
Initial valuenone
Applies toAll four border sides (shorthand for top, right, bottom, left)
InheritedNo
AnimatableNo
Common useCards, boxes, form fields, dividers, and decorative frames

Default Value

The default value of border-style is none, meaning no border is displayed until you choose a visible style such as solid or dashed.

You can pass one to four values to style all sides at once or assign a different style to each edge.

💎 Property Values

The border-style property accepts standard CSS border style keywords.

ValueDescription
noneNo border is displayed
solidA single solid line
dashedA series of dashed lines
dottedA series of dotted lines
doubleTwo solid lines with space between them
grooveA 3D grooved border that looks carved in
ridgeA 3D ridged border that looks raised out
insetA 3D inset border that looks embedded
outsetA 3D outset border that looks raised
hiddenSame as none, but can still affect table layout
previewsolid
previewdotted
previewdashed
previewdouble
previewgroove
previewridge
previewinset
previewoutset

One to Four Values

border-style follows the same shorthand pattern as margin and padding. One value styles every side; up to four values target top, right, bottom, and left in that order.

  • One value — applies to all four sides.
  • Two values — first value for top and bottom, second for right and left.
  • Three values — top, right/left, bottom.
  • Four values — top, right, bottom, left.

One value (solid)

Same style on every side

Four values (solid dashed dotted double)

Different style per side

border-style vs Side Longhands vs border

PropertyTargetsBest for
border-styleStyle on all four sides (1–4 values)Setting the same or mixed line styles around a box
border-top-style (and other side longhands)Style on one physical side onlyAccenting a single edge without affecting the others
borderWidth, style, and color togetherQuick one-line borders when all three parts are the same

👀 Live Preview

A box with a solid blue border on all sides:

This element has a solid border style.

Uses border-style: solid; with border-width and border-color longhands.

Examples Gallery

Try border-style with solid, dashed, dotted, double, and four-value shorthand borders.

📚 Basic Border Styles

Set border-style with width and color longhands so each line is visible, matching the reference tutorial.

Example 1 — Solid, Dashed, and Dotted Borders

Apply three different border styles to separate div elements, each with its own color.

border-style-basic.html
<style>
  .solid-border {
    border-style: solid;
    border-width: 2px;
    border-color: black;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
  }
  .dashed-border {
    border-style: dashed;
    border-width: 2px;
    border-color: blue;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
  }
  .dotted-border {
    border-style: dotted;
    border-width: 2px;
    border-color: red;
    padding: 0.75rem 1rem;
  }
</style>

<h1>Different Border Styles</h1>
<div class="solid-border">Solid Border</div>
<div class="dashed-border">Dashed Border</div>
<div class="dotted-border">Dotted Border</div>
Try It Yourself

How It Works

Each class sets a different border-style keyword. Width and color longhands make each border visible on all four sides.

Example 2 — Border Style Showcase

Showcase solid, dotted, dashed, and double styles on full borders around each box.

border-style-showcase.html
<style>
  .border-examples div {
    border-width: 2px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
  }
  .solid {
    border-style: solid;
    border-color: #3498db;
  }
  .dotted {
    border-style: dotted;
    border-color: #e74c3c;
  }
  .dashed {
    border-style: dashed;
    border-color: #2ecc71;
  }
  .double {
    border-style: double;
    border-width: 4px;
    border-color: #f39c12;
  }
</style>

<div class="border-examples">
  <div class="solid">Solid Border</div>
  <div class="dotted">Dotted Border</div>
  <div class="dashed">Dashed Border</div>
  <div class="double">Double Border</div>
</div>
Try It Yourself

How It Works

Each style keyword changes how the border line is drawn. double needs enough width (usually 3px or more) to show two visible lines.

🎨 Shorthand and Practical Styles

Use multiple values for per-side styles, or pick decorative styles like double for cards.

Example 3 — Four-Value Shorthand

Assign a different style to each side with four values: top, right, bottom, left.

border-style-shorthand.css
.shorthand-box {
  border-style: solid dashed dotted double;
  border-width: 3px;
  border-color: #2563eb;
  padding: 1rem;
  max-width: 16rem;
}
Try It Yourself

How It Works

The four values map to top, right, bottom, and left in that order — the same shorthand pattern used by margin and padding.

Example 4 — Double Border Card

Use a double border style for a decorative card frame that stands out from flat UI.

border-style-double-card.css
.card {
  border-style: double;
  border-width: 6px;
  border-color: #334155;
  padding: 1rem;
  background: #fff;
  max-width: 16rem;
}
Try It Yourself

How It Works

double draws two parallel lines. A wider border width (6px here) gives enough space for both lines to appear clearly.

🧠 How border-style Works

1

You choose a line style

Set solid, dashed, dotted, or another border style keyword.

Style rule
2

You add width and color

Pair the style with border-width and border-color.

Border setup
3

The browser draws each border side

One value styles all four sides. Multiple values let you mix styles per edge.

All sides
=

Styled border frame

Your element gets a visible border that defines its shape and emphasis.

Universal Browser Support

The border-style property is supported in all major browsers, including Chrome, Firefox, Safari, Edge, Opera, and Internet Explorer. It is one of the most reliable CSS border properties.

Baseline · All browsers

Reliable border styles on every platform

Chrome, Firefox, Safari, Edge, and Opera all support border-style consistently.

100% Universal support
Google Chrome69+ · Desktop & Mobile
Full support
Mozilla Firefox66+ · Desktop & Mobile
Full support
Apple Safari12.1+ · macOS & iOS
Full support
Microsoft Edge79+ · Chromium
Full support
Opera56+ · Modern versions
Full support
border-style property 100% supported

Bottom line: Use border-style freely in any project. It works consistently across all browsers.

Conclusion

The border-style property provides a variety of options for styling the border around an element, from simple lines to more complex effects like double and 3D styles.

By experimenting with different style keywords and shorthand values, you can enhance the visual appeal and user experience of your website with cards, form fields, callouts, and frames.

💡 Best Practices

✅ Do

  • Use solid for clear boxes, cards, and form field outlines
  • Try dashed or dotted for softer dividers and placeholders
  • Use four-value shorthand when each side needs a different style
  • Pair style with width and color longhands for predictable results
  • Use the border shorthand when setting all three parts at once
  • Give double enough width (usually 3px or more) to show two lines

❌ Don’t

  • Leave the value at none and expect a visible border
  • Use double with a 1px width and wonder why only one line shows
  • Use heavy 3D styles everywhere in modern flat UI
  • Forget border-width when using thin styles like dotted or dashed
  • Mix border-style shorthand with conflicting side longhands without a plan

Key Takeaways

Knowledge Unlocked

Five things to remember about border-style

Use these points when styling borders around any element.

5
Core concepts
02

none Default

Hidden by default.

Default
📝03

solid / dashed

Most common styles.

Values
⚙️04

Needs Width

Pair with longhands.

Setup
🔄05

Shorthand

Per-side control.

Pattern

❓ Frequently Asked Questions

The border-style property sets the line style of the border on all four sides of an element. You can use one value for every side or up to four values for top, right, bottom, and left.
The initial value is none, which means no border is displayed until you set a visible style such as solid or dashed.
If the value is none, no border appears. You also need border-width greater than zero and usually a color, or use the border shorthand.
One value applies to all sides. Two values set top/bottom and right/left. Three values set top, right/left, and bottom. Four values set top, right, bottom, and left in that order.
solid, dashed, and dotted are the most common for boxes, cards, and dividers. double, groove, ridge, inset, and outset create stronger decorative or 3D effects.

Practice in the Live Editor

Open the HTML editor, try border-style, and preview styled borders instantly.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful