The border-width Property in CSS

CSSWeb DevelopmentFront End Technology

The CSS border-width property is used to specify the width for border of an element. We can also set width for individual sides using border-top-width, border-right-width, border-left-width and border-right-width properties.

Syntax

The syntax of CSS border-width property is as follows−

Selector {
   border-width: /*value*/
}

Example

The following examples illustrate CSS border-width property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
#main {
   border-bottom-width: 20px;
   border-bottom-left-radius: 40px;
   border-bottom-right-radius: 40px;
}
div {
   margin: auto;
   height: 100px;
   width: 80px;
   border-style: double;
   border-width: 5px;
}
div > div {
   margin-top: 15px;
   height: 50px;
   width: 50px;
   border-style: dashed;
   border-color: red;
   border-width: thin;
   text-align: center;
   line-height: 50px;
}
</style>
</head>
<body>
<div id="main">
<div>demo</div>
</div>
</body>
</html>

Output

This gives the following output −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
p {
   padding: 2%;
   border-style: ridge;
   border-width: 4px;
   border-color: indianred;
}
q {
   border-style: solid;
   border-width: thin;
   text-align: center;
   font-style: italic;
}
</style>
</head>
<body>
<p>
Student details are covered here.
</p>
<hr>
<q>Education is the most powerful weapon which you can use to change the world.</q>
</body>
</html>

Output

This gives the following output −

raja
Published on 06-Jan-2020 07:47:48
Advertisements