🎯 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.