Skip to content
Related Articles

Related Articles

CSS | border-top Property

View Discussion
Improve Article
Save Article
  • Last Updated : 02 Aug, 2022

The border-top property in CSS is used to set all top border properties in one line. This property is used to set the width, style and color of top border.

Syntax: 

border-top: border-width border-style border-color|initial|inherit;

Default Value 

  • initial

Property Values: 

  • border-width: It is used to set the width of border.
  • border-style: It is used to set the style of border. Its default value is ‘none’.
  • border-color: It is used to set the color of border.
  • initial: This property is used to set border-top to its default value.
  • inherit: This property is inherited from its parent.

Example: 

html




<!-- HTML code to illustrates
border-top property -->
<!DOCTYPE html>
<html>
    <head>
        <title>border-top property</title>
         
        <!-- border-top CSS property -->
        <style>
            h1 {
                border-top: 5px solid green;
            }
             
            h2 {
                border-top: 4px dotted black;
            }
        </style>
    </head>
     
    <body style = "text-align:center">
         
        <h1>GeeksforGeeks</h1>
        <h2>border-top property</h2>
    </body>
</html>                   


Output: 

Supported Browsers: The browser supported by border-top property are listed below: 

  • Google Chrome 1.0 and above
  • Edge 12 and above
  • Internet Explorer 4.0 and above
  • Firefox 1.0 and above
  • Opera 3.5 and above
  • Safari 1.0 and above
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!