A border appears only when the style is not none. Width defaults to medium and color to currentColor when omitted. For every side at once, use border. For a logical start edge that follows writing mode, use border-block-start.
Baseline · Widely available.
Not deprecated and not experimental. The border-top shorthand has been supported across browsers since the early days of CSS.
Choose double. The browser draws two lines with a gap between them.
Give it room.6px is wide enough for both lines and the space between.
Set the color. Teal fills both top lines.
Still top-only. The shorthand applies the effect to the physical top edge alone.
Edge Cases & Pitfalls
If the top border disappears or looks wrong, check these first.
style
No style means no top border
border-top: 3px #000 still looks empty because style defaults to none. Always include solid or another style keyword.
reset
The shorthand resets omitted parts
Writing border-top: thick green after border-top-style: dotted resets style to none. Include the style in the shorthand, or set longhands after it.
logical
Physical top is not always “start”
border-top stays on the screen’s top edge. In vertical writing modes, use border-block-start when the line should follow the block-start side instead.
size
Borders add to the box by default
With the default content-box sizing, a top border grows the element’s outer height. Use box-sizing: border-box to keep height inclusive of the border.
sides
Need every side the same?
Use border instead. Reach for border-top when only the top edge should change.
Compatibility
Browser Support
border-top is a browser CSS property for the box model. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
border-top
Supported in all modern browsers and Internet Explorer. The side shorthand has been part of CSS since the earliest versions.
100%Universal support
Google ChromeAll versions
Full support
Mozilla FirefoxAll versions
Full support
Apple SafariAll versions
Full support
Microsoft EdgeAll versions
Full support
OperaAll versions
Full support
Samsung InternetAll versions
Full support
Internet ExplorerAll versions
Full support
border-topWidely supported
Bottom line: Safe everywhere for top-edge width, style, and color. Prefer the shorthand when the top side is the only edge you need. It is not a runtime API.
Remember
Key Takeaways
Role: one shorthand for width, style, and color on the physical top edge.
Style required: initial style is none. Width or color alone will not draw.
Physical edge: always the screen top — not writing-mode aware like border-block-start.
Shorthand reset: omitted parts fall back to defaults, including style none.
One line: use border-top when only the top edge needs a border — and always include a style keyword.
Frequently Asked Questions
It is a shorthand that sets border-top-width, border-top-style, and border-top-color on the physical top edge in one declaration.
A visible style is required. The initial style is none, so width or color alone will not draw a line. Use solid, dashed, dotted, or another style.
You can write width, style, and color in any order. The common pattern is width then style then color, for example border-top: 3px solid black.
border-top always targets the physical top edge. border-block-start follows writing-mode, so in vertical text it may map to a side instead of the top.
Yes. Like other border shorthands, omitted parts reset to their defaults. If you omit style, it becomes none and the border disappears.
It is Baseline Widely available and works in all modern browsers and Internet Explorer. It is a browser CSS property, not a Node.js feature.