A border only appears when the style is not none. Width defaults to medium and color to currentColor when omitted. For one side only, use border-top and the other side longhands instead.
Baseline · Widely available.
Not deprecated and not experimental. The border 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 lines.
Same on all sides. The shorthand still applies the effect to top, right, bottom, and left together.
Edge Cases & Pitfalls
If the border disappears or looks wrong, check these first.
style
No style means no border
border: 2px #000 still looks empty because style defaults to none. Always include solid or another style keyword.
image
border resets border-image
The shorthand sets border-image back to none. Declare border-image after border if you need an image border.
size
Borders add to the box by default
With the default content-box sizing, a border grows the element’s outer size. Use box-sizing: border-box to keep width and height inclusive of the border.
sides
One shorthand cannot style sides differently
border paints all four sides the same. For a bottom-only line, use border-bottom or set the longhands separately.
outline
Outline is not a border
outline draws outside the border edge and does not take layout space. Do not swap them when you need box-model size.
Compatibility
Browser Support
border is a browser CSS property for the box model. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
border
Supported in all modern browsers and Internet Explorer. The 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
borderWidely supported
Bottom line: Safe everywhere for width, style, and color. Prefer the shorthand when all four sides match. It is not a runtime API.
Remember
Key Takeaways
Role: one shorthand for width, style, and color on all four sides.
Style first: without a visible style, width and color do nothing.
Resets image:border sets border-image back to none.
Not inherited. Defaults: width medium, style none, color currentColor.
One line:border: 2px solid black; draws the same line on every side — after you include a style.
Frequently Asked Questions
It is a shorthand that sets border-width, border-style, and border-color on all four sides in one declaration.
A border needs a visible style. 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: 2px solid black.
Yes. Using the border shorthand sets border-image back to its initial value (none). Set border-image after border if you need both.
Border is part of the box model and takes up space. Outline is drawn outside the border edge and does not affect layout size.
The border shorthand is Baseline Widely available and works in all modern browsers and Internet Explorer. It is a browser CSS property, not a Node.js feature.