CSS border-top-style Property

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

What You’ll Learn

The border-top-style property defines the line style of the top border on an element. It is useful when you want the top edge styled differently from the other sides.

01

Top Style

Physical top edge.

02

solid

Continuous line.

03

dashed / dotted

Soft dividers.

04

3D Styles

groove, ridge, inset.

05

none Default

No border by default.

06

Longhand

Part of border-top.

Definition and Usage

The border-top-style CSS property specifies the style of the top border of an element. This property allows you to control the appearance of the top edge, enhancing design and visual hierarchy on your web pages.

By choosing different border styles such as solid, dashed, or dotted, you can create a variety of effects for section dividers, card accent bars, headers, and horizontal highlights.

💡
Beginner Tip

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

📝 Syntax

The syntax for border-top-style is straightforward:

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

Basic Example

border-top-style.css
p {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-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 top border.
  • Common values include solid, dashed, and dotted.
  • 3D-style keywords include groove, ridge, inset, and outset.
  • Pair with width and color longhands, or use the border-top shorthand.
  • Related longhands: border-top-width and border-top-color.

⚡ Quick Reference

QuestionAnswer
Initial valuenone
Applies toTop border style only
InheritedNo
AnimatableNo
Common useSection dividers, card accent bars, header lines

Default Value

The default value of border-top-style is none, meaning no top border is displayed until you choose a visible style.

💎 Property Values

The border-top-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

Top Border Style and Writing Modes

border-top-style always styles the physical top side. Vertical writing modes do not move the border — compare with border-block-start-style when building writing-mode-aware layouts.

Horizontal (writing-mode: horizontal-tb)

Dashed top border on the top edge

Vertical (writing-mode: vertical-rl)

Top border style still on the physical top

border-top-style vs related properties

PropertyTargetsBest for
border-top-stylePhysical top border styleSection dividers, card accent bars, and horizontal highlights
border-block-start-styleLogical block-start border style (writing-mode-aware)Header accents that follow vertical writing modes
border-topWidth, style, and color on the top sideSetting the full top border in one rule

👀 Live Preview

A box with a solid blue top border style:

This element has a solid top border style.

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

Examples Gallery

Try border-top-style with solid, dashed, dotted, and double top borders.

📚 Basic Top Border Styles

Set the top border style with width and color longhands so the line is visible.

Example 1 — Top Border Styles (Reference)

Apply solid, dotted, and dashed styles to the top border, matching the reference tutorial.

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

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

How It Works

Each class sets only the top border style, width, and color. The style keyword controls how the top line is drawn — solid, dotted, or dashed.

Example 2 — Double Top Border

Use double for a two-line top border effect. Give it enough width to show both lines.

border-top-style-double.css
.card {
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #f39c12;
  padding: 1rem;
  background: #fffbeb;
}
Try It Yourself

How It Works

double draws two parallel lines on the top edge. A width of at least 3px is usually needed for both lines to appear clearly.

🎨 Practical UI Styles

Use dashed styles for section dividers and vertical writing comparisons.

Example 3 — Dashed Section Divider

Use a dashed top border style for a softer horizontal section divider.

border-top-style-dashed.css
.callout {
  border-top-style: dashed;
  border-top-width: 3px;
  border-top-color: #7c3aed;
  padding: 0.75rem 1rem;
  background: #faf5ff;
}
Try It Yourself

How It Works

dashed breaks the top border into short segments — a common pattern for separating content sections.

Example 4 — border-top-style in Vertical Writing

In vertical writing, border-top-style stays on the physical top — unlike border-block-start-style.

border-top-style-vertical.html
<style>
  .vertical-box {
    writing-mode: vertical-rl;
    display: inline-block;
    border-top-style: solid;
    border-top-width: 4px;
    border-top-color: #059669;
    padding: 0.75rem 1rem;
    background: #ecfdf5;
  }
</style>

<div class="vertical-box">
  Top border style stays on the physical top
</div>
Try It Yourself

How It Works

Vertical writing changes text flow but not the physical top edge. For a block-start accent that follows the writing mode, use border-block-start-style instead.

🧠 How border-top-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-top-width and border-top-color.

Border setup
3

The browser draws the top edge

Only the physical top border uses that line style. Right, bottom, and left sides stay unchanged.

Top edge
=

Styled top accent

Your element gets a clear visual separator on the physical top edge.

Universal Browser Support

The border-top-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 top border styles on every platform

Chrome, Firefox, Safari, Edge, and Opera all support border-top-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-top-style property 100% supported

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

Conclusion

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

By experimenting with different style keywords, you can enhance the visual appeal and user experience of your website with section dividers, card accent bars, and decorative top accents.

💡 Best Practices

✅ Do

  • Use solid for clear section dividers and top accent lines
  • Try dashed or dotted for softer horizontal dividers
  • Use border-block-start-style when the accent must follow vertical writing modes
  • Pair style with width and color longhands for predictable results
  • Use the border-top shorthand when setting all three parts
  • Give double enough width (usually 3px or more) to show two lines

❌ Don’t

  • Leave the value at none and expect a visible border
  • Expect border-top-style to move to the side in vertical writing modes
  • Use heavy 3D styles everywhere in modern flat UI
  • Mix physical and logical style properties without a clear reason
  • Forget width when using thin styles like dotted or dashed

Key Takeaways

Knowledge Unlocked

Five things to remember about border-top-style

Use these points when styling the physical top edge.

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

One Edge Only

Other sides unchanged.

Scope

❓ Frequently Asked Questions

The border-top-style property sets the line style of the border on the physical top side of an element only.
The initial value is none, which means no top 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-top-width greater than zero and usually a color, or use the border-top shorthand.
border-top-style always styles the physical top edge. border-block-start-style follows writing mode, so in vertical writing it may appear on the side instead of the top.
solid, dashed, and dotted are the most common for section dividers and top accent lines. double, groove, ridge, inset, and outset create stronger visual effects.

Practice in the Live Editor

Open the HTML editor, try border-top-style, and preview styled top 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