CSS | Borders
CSS border properties allows us to set the style, color and width of the border.
Note : Different properties can be set for all the different borders i.e.top border, right border, bottom border and left border.
Properties of CSS Borders :
- Border Style : The border-style property specifies the type of border. None of the other border properties will work without setting the border style.
Following are the types of borders:*dotted – Defines a dotted border
*dashed – Defines a dashed border
*solid – Defines a solid border
*double – Defines a double border
*groove – Defines a 3D grooved border.
*ridge – Defines a 3D ridged border.
*inset – Defines a 3D inset border.
*outset – Defines a 3D outset border.
*none – Defines no border
*hidden – Defines a hidden border
Example:<!DOCTYPE html><html><head><style>p.dotted {border-style: dotted;}p.dashed {border-style: dashed;}p.solid {border-style: solid;}p.double {border-style: double;}</style></head><body><h2>The border-style Property</h2><p>Geeksforgeeks</p><pclass="dotted">A dotted border.</p><pclass="dashed">A dashed border.</p><pclass="solid">A solid border.</p><pclass="double">A double border.</p></body></html>chevron_rightfilter_noneOUTPUT:
- Border Width : Border width sets the width of the border . Width of the border can be in px, pt, cm or thin, medium and thick.
Example:<style>p{border-style:solid;border-width:8px;}</style><body><p>Geeksforgeeks<p>Border properties</p><\body>chevron_rightfilter_noneOUTPUT:
- Border Color : This property is used to set the color of the border. Color can be set using the color name, hex value or rgb value. If the color is not specified border inherits the color of the element itself.
Example:
<style>p{border-style:solid;border-color:red}</style><body><p>GeeksforgeeksBorder properties:color</p><\body>chevron_rightfilter_noneOUTPUT:
- Border individual sides : Individual sides can be set with different properties.
*If border properties has 4 values then:
border-style : solid dashed dotted doubleSolid : top border
Dashed : right border
Dotted : bottom border
Double : left border<!DOCTYPE html><html><head><style>p{border-style:solid dashed dotted double;border-color:red;}</style></head><body><p>Geeksforgeeks</p><p>Border properties:color</p></body></html>chevron_rightfilter_noneOUTPUT:
*If border properties has 3 values then:
border-style: solid dotted doubleSolid:top border
Dotted: Left and right border
Double: bottom border<!DOCTYPE html><html><head><style>p{border-style:solid dashed dotted;border-color:blue;}</style></head><body><p>Geeksforgeeks</p><p>Border properties:color</p></body></html>chevron_rightfilter_noneOUPUT:
*If border properties has 2 values
border-style:solid dottedSolid:top and bottom border
Dotted: right and left border<!DOCTYPE html><html><head><style>p{border-style:solid dashed;border-color:blue;}</style></head><body><p>Geeksforgeeks</p><p>Border properties:color</p></body></html>chevron_rightfilter_noneOUTPUT:
*If border properties has 1 value
border-style:dotted
Dotted:top, bottom, left and right border<!DOCTYPE html><html><head><style>p{border-style:solid ;border-color:green;}</style></head><body><p>Geeksforgeeks</p><p>Border properties:color</p></body></html>chevron_rightfilter_noneOUTPUT:
Recommended Posts:
- Gradient borders
- Borders in bootstrap with examples
- How to insert HTML content into an iFrame using jQuery?
- How to get the child node index in JavaScript?
- How to use jQuery in Angular ?
- How to restrict input box to allow only numbers and decimal point JavaScript?
- How to get the height of device screen in JavaScript ?
- How to get the elements of one array which are not present in another array using JavaScript?
- How do you get the length of a string in JQuery?
- How to determine which element the mouse pointer move over using JavaScript ?
- How to add innerHTML to print page?
- How to get the type of DOM element using JavaScript?
- How to disable dragging an image from an HTML page using JavaScript/jQuery ?
- How to check whether an object exists in javascript ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



