CSS Property border-top

border-top shorthand property defines the width, color, and style of the top border.


Inherited No.
Version CSS1
JavaScript syntax object.style.borderTop="5px solid red"
Applies to All elements.

CSS Syntax

border-top: border-width border-style border-color;

Property Values

The property values are listed in the following table.

Value Description
border-top-width Set the width of the top border
border-top-style Set the style of the top border
border-top-color Set the color of the top border
inherit Inherit the border-top property from the parent element

Browser compatibility

border-top Yes Yes Yes Yes Yes


An example showing how to use border-top CSS property.

    div {<!-- w w  w  .  ja v  a 2  s  .  c  o m-->
        border-top: 3px dashed darkkhaki;
        background: lightyellow;

Click to view the demo