Border Shorthand Property

Last updated: 2026-09-13

border Border Shorthand Property

The border shorthand property is one of the most commonly used in CSS, letting you set an element's border width, style, and color in a single declaration. The border wraps around the element's content, just inside the padding, and is a key part of the box model. With border you can quickly give any element a visible outline.

Category
Initial Valuemedium none currentcolor
InheritedNo
Applies Toall
Animation Typeshadow
CSS VersionCSS1
StatusStandard

📝 Syntax

border: <border-width> || <border-style> || <color>;

⚙️ Values

ValueTypeDescription
<border-width> || <border-style> || <color>ValueShorthand for border width, style, and color

▶ Example

Edit the code below and see the live result in the playground:

🌐 Browser Support

Browser ChromeChrome EdgeEdge FirefoxFirefox SafariSafari OperaOpera
border v1 v12 v1 v1 v1
Supported in all major browsers
Tip: The border shorthand sets all four sides at once. To style a single side, use border-top, border-right, border-bottom, or border-left instead.
Warning: The border shorthand resets any previously set border-width, border-style, or border-color. If you only need to change one of them, prefer the corresponding longhand property.

❓ FAQ

QWhat is the difference between border and outline?
Aborder is part of the box model and is drawn around the content and padding, so it takes up space and affects element size and layout. outline is drawn outside the border, takes up no space, and does not affect layout, which makes it ideal for keyboard focus indicators. Use border for decorative borders and outline for space-free visual cues, especially for focus states.
QWhy can't I see a border after setting it?
AThe most common cause is forgetting to set border-style. Its default value is none, so you must explicitly specify a style (like solid or dashed) for a border to render. Also check that border-width is not 0 and that no other rule overrides the color. The simplest fix is to use the border shorthand to set all three at once.
QDoes the order of the three values in the border shorthand matter?
AThere is no strict requirement — browsers identify values by type automatically — but the conventional order is width, then style, then color, e.g. border: 1px solid #ccc;. Note that omitting the style defaults to none (no visible border), and omitting the color defaults to currentcolor (the text color). Keeping a consistent order also makes the code easier to maintain.
QHow do I set different borders on the four sides?
AUse the per-side shorthands border-top, border-right, border-bottom, and border-left, or set the whole border first and then override individual sides. For example, border: 1px solid #ddd; border-bottom: 3px solid #e74c3c; produces a highlighted bottom border with a regular border on the other three sides.

📚 Related Tutorials

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏