The border of the visual elements includes the border style, width and the color. These three properties are defined separately.
We start with the width of the border.
The border may be thick, thin or medium size. The width of the border may also be defined by the values measured in px, em or other units.
border-width property represents the width of the four sides.
border-top-width, border-right-width, border-bottom-width and border-left-width properties define the width of the top, right, bottom and left sides respectively.
what about more than one values for the border-width?
Different values for the width of the four sides may also be defined in one border-width property.
10px is the width of all of the four sides.
top and bottom sides have width of 10px, and the width of the remaining two sides is 20px.
border-width:10px 20px 30px;
10px, 20px and 30px represent the width of top, right and bottom sides. And left side has the same width as right (20px).
border-width:5px 10px 15px 20px;
These four values define width for the top, right, bottom and top sides.
The above given rule is general and applicable on border-color, border-style and many other properties that you'll encounter in next tutorials (talking about the different values for the same property).
It defines the background-color of the border. The color value may be specified by rgb or hexadecimal values.
There are many predefined styles for the border. The following are the styles of border.
All of the above given properties for the border can be combined in one border property.
<div style="border:width style color;"> <div style="border:10px groove gray;"></div>Try </>
10px is the border-width, groove is the border-style and gray is the border-color.
It defines the radial shape of the four corners of the border. The borders may be rounded or rectanglular shaped. The value of the border-radius may be in px, em units. Or the value may be in percentage (%).
First shape is rectanglar and the second one is rounded shape.
If the values of width and height are equal and the value of border-radius property is 50%, then it rectanglular shape becomes circular shape.
Was this article helpful?