EN
CSS - add border
0
points
In this article, we would like to show you how to add border to the element using CSS.
Quick solution:
div {
border: 1px solid red; /* border: width, style, color */
}
Practical example
In this example, we add basic solid border to the div element.
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<head>
<style>
div {
height: 100px;
width: 100px;
border: 3px solid red; /* <--- required */
}
</style>
</head>
<body>
<div></div>
</body>
</html>
Different border styles
In this section, we present some other border styles.
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<head>
<style>
.solid { border: 2px solid; }
.dotted { border: 2px dotted; }
.dashed { border: 2px dashed; }
.double { border: 2px double; }
.groove { border: 2px groove; }
.inset { border: 2px inset; }
.outset { border: 2px outset; }
</style>
</head>
<body>
<p class="solid">solid border</p>
<p class="dotted">dotted border</p>
<p class="dashed">dashed border</p>
<p class="double">double border</p>
<p class="groove">groove border</p>
<p class="inset">inset border</p>
<p class="outset">outset border</p>
</body>
</html>
Note:
Go to the following article to see the CSS border property summary: