Open In App

CSS border-style Property

CSS border-style Property is used to set the border style, and it is a shorthand property that sets the line style for all four sides of an element’s border.

Note: The border-style property can take One to Four values at a time.



Default Value: none

CSS border-style Property Syntax:

border-style: value;

CSS border-style Property Values:

CSS border-style property is a shorthand for:

The below examples illustrate the use of the border-style property.



CSS border-style property Example :

In This example we are using is using CSS border-style property which contain only one value for all borders. 




<!DOCTYPE html>
<html>
   
<head>
    <title>Dotted Borders</title>
    <style>
    .GFG {
        border-style: dotted;
        border-width: 6px;
        background: #009900;
        padding: 30px;
        text-align: center;
        width: 300px;
        height: 120px;
    }
    </style>
</head>
 
<body>
    <div class="GFG">
    <h2>GeeksforGeeks</h2> </div>
</body>
   
</html>

Output:

CSS border-style property Example Explanation:

Here is the explanantion of above exmaple.

CSS border-style property example with multiple values:

In this example The CSS border-style property accepts multiple values to define different styles for each side of the border.




<!DOCTYPE html>
<html>
   
<head>
    <title>Dotted Borders</title>
    <style>
    .GFG {
        border-style: solid double dashed dotted;
        border-width: 6px;
        background: #009900;
        padding: 30px;
        text-align: center;
        width: 300px;
        height: 120px;
    }
    </style>
</head>
 
<body>
    <div class="GFG">
    <h2>GeeksforGeeks</h2> </div>
</body>
   
</html>

Output:

CSS border-style property with multiple values Example Explanation:

Here is the implemantation of above example.

CSS border-style Property Use Cases:

1. How to create and style border using CSS ?

we can use border properties like style, width, and color to create and style borders in CSS.

2. How to create a Border around an HTML Element using CSS ?

Here we can use CSS properties like border-style, border-width, and border-color to create a border around HTML elements.

to

The browser supported by border-style Property are listed below: 


Article Tags :