Shorthand property that defines the different properties of all four sides of an element’s border in a single declaration. It can be used to set border-width, border-style and border-color, or a subset of these.
Overview tablemedium none currentColor
border-width
, border-style
, and border-color
.
border
border: <border-width> OR <border-style> OR <border-color>
border: inherit
inherit
, the element will inherit the border values set on its parent.
<border-width>
, <border-style>
, and <border-color>
. At least one of these must be present, and they may appear in any order.
<border-width>: A numeric value with any of the standard length units. The initial value is medium
, which most browsers will render as 3px. See the border-width property.
<border-style>: This takes any of the range of values available to the border-style property. The initial value is none
.
<border-color>: This takes any valid CSS color. See the border-color property. The initial value is currentColor
.
A simple example showing multiple <div>
s, identical in style except that they have different border
properties applied to them.
<div class="one"><p>One</p></div>
<div class="two"><p>Two</p></div>
<div class="three"><p>Three</p></div>
<div class="four"><p>Four</p></div>
<div class="five"><p>Five</p></div>
div {
width: 150px;
height: 150px;
margin: 1rem;
float: left;
}
p {
padding: 2rem;
}
.one {
border: 1px solid black;
}
.two {
border: 4px dashed;
}
.three {
border: dotted red;
}
.four {
border: 10px black;
}
.five {
border: 10px inset rgba(234,190,50,0.75);
}
Usage
* It is usual to first use the border shorthand property to set the state of a default box, and then override it where needed, using the more specific shorthand properties border-width, border-style, and border-color. Each of these properties may take up to four values, respective to the sides of the box.
border
property with the properties specific to each individual side: border-top
, border-right
, border-bottom
, and border-left
. Each of these properties may take up to three values, defining the appearance (width, style, and color) of the designated side.border-top-width
, border-top-style
, border-top-color
, border-right-width
, border-right-style
, border-right-color
, border-bottom-width
, border-bottom-style
, border-bottom-color
, border-left-width
, border-left-style
, border-left-color
.
border
is the concatenated result of the initial values of each component.border-bottom
can be used as a divider between vertically laid out items, such as navigation menu items, or a new section. Authors will sometimes use this technique rather than inserting an <hr/>
element in the HTML.border-bottom
properties for link underlining rather than text-decoration: underline
, as it affords the designer more control.border
border
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4