CSS Border
By using the various commands of CSS, you can set the colors, width, style and many different properties of the borders.Width of the border
The width of the borders can be specified by using the property, border-width. The value is specified in terms of pixels or keywords. The keywords that can be used are thin, medium or thick. The ways to specify the border width are given below:p.oneb {border-width: 5px}
p.twob {border-width: thick thin}
p.threeb {border-width: 5px 10px 2px}
p.fourb {border-width: 5px 10px 1px medium}
The above borders will look as follows:
This defines width of all borders
Top, bottom borders will be thick & right, left borders will be thin
Top will be 5px, right & left 10px, bottom will be 2px
Top will be 5px, right 10px, bottom 1px & left medium
Styles of the border
There are various types of borders that can be used. By using the border-style property, various types of border styles can be displayed. The various types of borders that can be set are given below:span.solid {border-style: solid}
span.double {border-style: double}
span.groove {border-style: groove}
span.dotted {border-style: dotted}
span.dashed {border-style: dashed}
span.inset {border-style: inset}
span.outset {border-style: outset}
span.ridge {border-style: ridge}
span.hidden {border-style: hidden}
The result of these border styles are given below:
This is solid borderYou can specify different styles for different borders.This is double border
This is grooved border
This is dotted border
This is dashed border
This is inset border
This is outset border
This is ridged border
Example:
Output:Top and bottom are dotted while left and right are double
Top is grooved, right and left are solid while bottom is dotted
Top is grooved, right is double, bottom is dashed and left is solid
Top and bottom are dotted while left and right are double
Top is grooved, right and left are solid while bottom is dotted
Top is grooved, right is double, bottom is dashed and left is solid
Color of the border
The color of the border is set by using the border-color property. The value of the border-color property can be a color name, rgb value or a hexadecimal number.Example:
Output: Border is single coloredTop & bottom #ff0000, right & left #0000ffTop #ff0000, right & left 00ff00, bottom blueTop #ff0000, right black, bottom #0000ff, left rgb(250,0,255)
Border is single coloredTop & bottom #ff0000, right & left #0000ffTop #ff0000, right & left 00ff00, bottom blueTop #ff0000, right black, bottom #0000ff, left rgb(250,0,255)
Some other commands
border-top The border-top allows to set various properties of the top border in a single declaration.border-right You can set all the properties of the right border by using border-right.
border-bottom All the properties of the bottom border can be set by using a single declaration, border-bottom.
border-left The bottom-left allows to set all the properties of the left border.
Example:
Output:All the properties are specified in a single declaration.
All the properties are specified in a single declaration.
border-top-color The color of the top border is specified by using border-top-color.border-right-color The color of the right border is specified by using border-right-color.
border-bottom-color The color of the bottom border is specified by using border-bottom-color.
border-left-color The color of the left border is specified by using border-left-color.
Example:
Output: The colors of all the borders are specified.
border-top-style The style of the top border can be specified by using border-top-style.The colors of all the borders are specified.
border-right-style The style of the right border is specified by using border-right-style.
border-bottom-style The style of the bottom border is specified by using border-bottom-style.
border-left-style The style of the left border can be specified by using border-left-style.
Example:
Output:This paragraph has the width of all the borders specified
border By using border, all the properties of the border can be set by using a single command.This paragraph has the width of all the borders specified
Example:
Output: The properties have been specified in a single command
The properties have been specified in a single command
