Join MDN and developers like you at Mozilla's View Source conference, November 2-4 in Portland, Oregon. Learn more at


The border CSS property is a shorthand property for setting the individual border property values in a single place in the style sheet. border can be used to set the values for one or more of: border-width, border-style, border-color.

Like all shorthand properties, a missing value for one of the longhand properties is set to the corresponding initial value. Also note that border-image, though not settable using this shorthand, is reset to its initial value, that is, none. This allows to use border to reset any border settings set earlier in the cascade. As the W3C intends to preserve this property in future level of the spec, it is recommended to use this method to reset border settings.

Note: While the border-width, border-style, and border-color shorthand properties accept up to four values, allowing one to set different width, style or color values for the different border edges, this property only accepts a single value for each property, leading to the same border for all four edges.


border: 1px;
border: 2px dotted;
border: medium dashed green;


Default value medium is used if absent. See border-width.
Default value none is used if absent. See border-style.
A <color> denoting the color of the border. If not set, its default value is the value of the element's color property (the text color, not the background color). See border-color.

Formal syntax

<br-width> || <br-style> || <color>

<br-width> = <length> | thin | medium | thick
<br-style> = none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
<color> = <rgb()> | <rgba()> | <hsl()> | <hsla()> | <hex-color> | <named-color> | currentcolor | <deprecated-system-color>

<rgb()> = rgb( <rgb-component>#{3} )
<rgba()> = rgba( <rgb-component>#{3} , <alpha-value> )
<hsl()> = hsl( <hue>, <percentage>, <percentage> )
<hsla()> = hsla( <hue>, <percentage>, <percentage>, <alpha-value> )
<named-color> = <ident>
<deprecated-system-color> = ActiveBorder | ActiveCaption | AppWorkspace | Background | ButtonFace | ButtonHighlight | ButtonShadow | ButtonText | CaptionText | GrayText | Highlight | HighlightText | InactiveBorder | InactiveCaption | InactiveCaptionText | InfoBackground | InfoText | Menu | MenuText | Scrollbar | ThreeDDarkShadow | ThreeDFace | ThreeDHighlight | ThreeDLightShadow | ThreeDShadow | Window | WindowFrame | WindowText

<rgb-component> = <integer> | <percentage>
<alpha-value> = <number>
<hue> = <number>



HTML Content

<div class="brd"> look at my borders </div>
<p>you can play with the css below to test properties changes</p>
<style contenteditable>
  .brd { border: 1px solid black;}

CSS Content

.brd { 
  border: 1px solid black;
style { 
  border: 1px dashed black;

Border demo

HTML Content

Click the different examples to see them in action:
<button>border: 2px solid #ccc;width: 300px</button>
<button>border: 20px solid #ccc;width: 300px</button>
Try it yourself: <input type="text" id="cd" value="border: 14px red dashed">

<div id="example">Result</div>

CSS Content

body {font: 14px/1.5 'Open Sans',sans-serif;}
button { color: #369; border: none; font-size: 14px; padding: 10px 0; background: transparent; display: block;}

JavaScript Content

document.addEventListener('click', function(ev) {
    var t =;
    var out = document.getElementById('example');
    if (t.tagName === 'BUTTON') {
var str = t.innerHTML; = str + ';transition: 0.5s';
}, false);
document.getElementById('cd').addEventListener('keyup', function(ev){
document.getElementById('example').style = this.value + ';transition: 0.5s';
}, false);


Specification Status Comment
CSS Backgrounds and Borders Module Level 3
The definition of 'border' in that specification.
Candidate Recommendation Technically removes the support for transparent as it is now a valid <color>; this has no practical influence.
Though it cannot be set to another value using the shorthand, border does now reset border-image to its initial value (none).
CSS Level 2 (Revision 1)
The definition of 'border' in that specification.
Recommendation Accepts the inherit keyword. Also accepts transparent as a valid color.
CSS Level 1
The definition of 'border' in that specification.
Recommendation Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 1.0 (1.7 or earlier) 4.0 3.5 1.0 (85)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? 1.0 (1.9.2) ? ? 1.0

See also