CSS Property border-top








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

Summary

ItemValue
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




Example

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

<!DOCTYPE HTML>
<html>
    <head>
    <style>
    div {<!-- w w  w  .  ja v  a 2  s  .  c  o m-->
        border-top: 3px dashed darkkhaki;
        background: lightyellow;
    }
    </style>
    </head>
    <body>
        <div>java2s.com</div>
    </body>
</html>

Click to view the demo