You are here: Reference > CSS > properties > border

border property

Browser support:
Sets up to three separate border properties, in a shorthand form.
With this property you can customize the borders that appear around HTML elements. You have control over the width, style and color of the border.

border-style: dotted
border-style: dashed
border-style: solid
border-style: double
border-style: inset
border-style: outset
border-style: groove
border-style: ridge
border-style: window-inset

JavaScript page for this property: border. You can find other example(s) there.

Possible values:

 One of the following values: 
 Any of the following values (use the space character to separate them, each value can be used only once): 
border-color
 One of the following values: 
<color>
transparent
-moz-use-text-color
border-style
 One of the following values: 
dotted
dashed
double
groove
hidden
inset
none
outset
ridge
solid
window-inset
-moz-bg-inset
-moz-bg-outset
-moz-bg-solid
border-width
 One of the following values: 
<border width in non-negative length>
medium
thin
thick
inherit

Description of values:

-moz-bg-inset
The border looks as though it were embedded in the canvas.
-moz-bg-outset
The border looks as though it were coming out of the canvas.
-moz-bg-solid
A solid line is drawn.
-moz-use-text-color
The color of the border should be the same as the text color.
border width in non-negative length
The width of the border in length units. For the supported length units, see the length page.
color
Color of the border. For the supported color values, see the colors page.
dashed
A series of short line segments is drawn.
dotted
A series of dots is drawn.
double
A double line border.
groove
The border looks as if it has been carved into the background.
hidden
Turns the border off.
inherit
Takes the value of this property from the computed style of the parent element.
inset
The border looks as though it were embedded in the canvas.
medium
Default.
none
Default. Border width is null.
outset
The border looks as though it were coming out of the canvas.
ridge
The border looks as if it's protruding out of the background.
solid
A solid line is drawn.
thick
Greater than the medium width.
thin
Less than the medium width.
transparent
Default. Underlying content will shine through.
window-inset
The border looks as though it were embedded in the canvas with an additional single line.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the margin, border and padding properties:
<head>
    <style>
        .outer {
            border: 1px solid #ffffff;
            background-color: #ffb08a;
        }
        .middle {
            margin: 20px;
            padding: 20px;
            border: 10px solid #000000;
            background-color: #ceb379;
        }
        .inner {
            height: 10px;
            border: 1px solid #ffffff;
            background-color: #ffffff;
        }
    </style>
</head>
<body>
    <table cellpadding="0px" cellspacing="10px">
        <tr>
            <td style="background-color: #ffb08a;">&nbsp;</td>
            <td>margin</td>
            <td style="background-color: #000000;">&nbsp;</td>
            <td>border</td>
            <td style="background-color: #ceb379;">&nbsp;</td>
            <td>padding</td>
        </tr>
    </table>
    
    <div class="outer">
        <div class="middle">
            <div class="inner"></div>
        </div>
    </div>
</body>
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content