Javatpoint Logo
Javatpoint Logo

CSS Border

CSS border is a key property used to characterize and style the borders around HTML components. Borders assume a vital part in website composition, assisting with making separation, emphasis, and stylish allure. In CSS, you can utilize a few border-related properties to control the style, variety, size, and shape of these borders. In this article, we will investigate these CSS border properties and how to really utilize them.

CSS Border Properties

The CSS border properties are utilized to determine the style, variety, width, and ebb and flow of the borders of a component. These properties include:

  • border-style
  • border-color
  • border-width
  • border-radius

1) CSS border-style

The Border style property is used to specify the border type which you want to display on the web page.

There are some border style values which are used with border-style property to define a border.

Value Description
none It doesn't define any border.
dotted It is used to define a dotted border.
dashed It is used to define a dashed border.
solid It is used to define a solid border.
double It defines two borders wIth the same border-width value.
groove It defines a 3d grooved border. effect is generated according to border-color value.
ridge It defines a 3d ridged border. effect is generated according to border-color value.
inset It defines a 3d inset border. effect is generated according to border-color value.
outset It defines a 3d outset border. effect is generated according to border-color value.

Example:

Output:

CSS Border

2) CSS border-width

The border-width property is used to set the border's width. It is set in pixels. You can also use the one of the three pre-defined values, thin, medium or thick to set the width of the border.

Note: The border-width property isn't utilized alone. It is constantly utilized with other border properties like "border-style" property to set the border first any other way it won't work.

Output:

CSS Border

3) CSS border-color

There are three strategies to set the color of the border.

  • Name: It determines the color name. For instance: "red".
  • RGB: It determines the RGB worth of the color. For instance: "rgb(255,0,0)".
  • Hex: It determines the hex worth of the color. For instance: "#ff0000".

Note: The border-color property isn't utilized alone. It is constantly utilized with other border properties like "border-style" property to set the border first any other way it won't work.

Example:

Output:

CSS Border





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA