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:
xxxxxxxxxx
1
div {
2
border: 1px solid red; /* border: width, style, color */
3
}
In this example, we add basic solid
border to the div
element.
xxxxxxxxxx
1
2
<html>
3
<head>
4
<style>
5
6
div {
7
height: 100px;
8
width: 100px;
9
border: 3px solid red; /* <--- required */
10
}
11
12
</style>
13
</head>
14
<body>
15
<div></div>
16
</body>
17
</html>
In this section, we present some other border styles.
xxxxxxxxxx
1
2
<html>
3
<head>
4
<style>
5
6
.solid { border: 2px solid; }
7
.dotted { border: 2px dotted; }
8
.dashed { border: 2px dashed; }
9
.double { border: 2px double; }
10
.groove { border: 2px groove; }
11
.inset { border: 2px inset; }
12
.outset { border: 2px outset; }
13
14
</style>
15
</head>
16
<body>
17
<p class="solid">solid border</p>
18
<p class="dotted">dotted border</p>
19
<p class="dashed">dashed border</p>
20
<p class="double">double border</p>
21
<p class="groove">groove border</p>
22
<p class="inset">inset border</p>
23
<p class="outset">outset border</p>
24
</body>
25
</html>
Note:
Go to the following article to see the CSS border property summary: