Sets border around HTML element padding.
<p style="border:5px solid red; ">First row - border:5px solid red</p>
Border property has three sections which are width, style and color.
Example:
<!DOCTYPE html />
<html>
<head>
<title> Box Model Border </title>
</head>
<body >
<p style="border:5px solid red; ">First row - border:5px solid red</p>
<p >Second row </p>
<p>Third row</p>
<p style="border-top: 5px solid red; border-bottom: 25px solid green;">
Forth row - border-top: 5px solid red;border-bottom: 25px solid green;
</p>
</body>
</html>
In the above code,
Result:
Border shorthand version:
Shorthand version is used to specify multiple lines of border properties in one line. Following example shows detailed and shorthand version.
Border detailed version | Border shorthand version |
---|---|
|
|
Property | Equal to | |
---|---|---|
1 |
border:5px solid red;
|
|
- Border width 5px is applied to top, right, bottom and left sides of the element. - Border style Solid is applied to top, right, bottom and left sides of the element. - Borer color Red is applied to top, right, bottom and left sides of the element. |
||
2 |
|
|
Here border is applied top and bottom sides of the element. |