CSS
π― What is border?
The border property creates a visible line around an HTML element.
It is commonly used to separate content and improve UI design.
π§© Parts of the border Property
The border property is made up of three main components:
1. Thickness (Width)
Defines how thick the border will be.
πΉ Values:
- thin β thin line
- medium β default medium line
- thick β thick line
- or specific values like 2px, 5px, etc.
2. Style
Defines how the border looks visually.
πΉ Values:
- none β no border
- solid β solid line
- dashed β dashed line
- dotted β dotted line
- double β double line
- groove β 3D grooved effect
- ridge β 3D ridged effect
- inset β sunken effect
- outset β raised effect
3. Color
Defines the color of the border.
πΉ Examples:
- red
- #333
- rgb(0, 0, 0)
π‘ Additional Values
- initial β Resets the element to default border settings
- inherit β Takes the border value from the parent element
π§± Example Usages
CSS
div {
border: 2px solid red; /* 2px thick, solid, red border */
}
CSS
p {
border: thick dashed blue; /* thick, dashed, blue border */
}
CSS
img {
border: none; /* removes border */
}
π§ In Summary
The border property is used to define the thickness, style, and color of an HTML elementβs border.
You can think of its structure like this:
CSS
border: thickness style color;
β Example
CSS
border: 3px dotted green;
This means: A 3-pixel thick, green, dotted border.
