files/en-us/web/css/reference/properties/border/index.md
The border shorthand CSS property sets an element's border. It sets the values of {{Cssxref("border-width")}}, {{Cssxref("border-style")}}, and {{Cssxref("border-color")}}.
{{InteractiveExample("CSS Demo: border")}}
border: solid;
border: dashed red;
border: 1rem solid;
border: thick double #32a1ce;
border: 4mm ridge rgb(211 220 50 / 0.6);
<section class="default-example" id="default-example">
<div class="transition-all" id="example-element">
This is a box with a border around it.
</div>
</section>
#example-element {
background-color: #eeeeee;
color: darkmagenta;
padding: 0.75em;
width: 80%;
height: 100px;
}
This property is a shorthand for the following CSS properties:
/* style */
border: solid;
/* width | style */
border: 2px dotted;
/* style | color */
border: outset #ff3333;
/* width | style | color */
border: medium dashed green;
/* Global values */
border: inherit;
border: initial;
border: revert;
border: revert-layer;
border: unset;
The border property may be specified using one, two, or three of the values listed below. The order of the values does not matter.
[!NOTE] The border will be invisible if its style is not defined. This is because the style defaults to
none.
<line-width>
medium if absent. See {{Cssxref("border-width")}}.none if absent. See {{Cssxref("border-style")}}.currentColor if absent. See {{Cssxref("border-color")}}.As with all shorthand properties, any omitted sub-values will be set to their initial value. Importantly, border cannot be used to specify a custom value for {{cssxref("border-image")}}, but instead sets it to its initial value, i.e., none.
The border shorthand is especially useful when you want all four borders to be the same. To make them different from each other, however, you can use the longhand {{Cssxref("border-width")}}, {{Cssxref("border-style")}}, and {{Cssxref("border-color")}} properties, which accept different values for each side. Alternatively, you can target one border at a time with the physical (e.g., {{Cssxref("border-top")}} ) and logical (e.g., {{Cssxref("border-block-start")}}) border properties.
Borders and outlines are very similar. However, outlines differ from borders in the following ways:
{{cssinfo}}
{{csssyntax}}
<div>I have a border, an outline, and a box shadow! Amazing, isn't it?</div>
div {
border: 0.5rem outset pink;
outline: 0.5rem solid khaki;
box-shadow: 0 0 0 2rem skyblue;
border-radius: 12px;
font: bold 1rem sans-serif;
margin: 2rem;
padding: 1rem;
outline-offset: 0.5rem;
}
{{EmbedLiveSample('Setting_a_pink_outset_border')}}
{{Specifications}}
{{Compat}}