Javatpoint Logo
Javatpoint Logo

CSS Transparent Border

We will understand the CSS transparent border. The CSS border property is utilized to create a transparent border. Let us first understand the CSS border property.

CSS Border

The CSS border property is used to add a border to the HTML element. It is the shorthand property that defines the border width, border style, and border color.

Syntax:

The "border" is the CSS property in the above-given syntax. Following are the descriptions of the border values:

  1. Border-width: The border-width is the value of width that is given to the border property to specify the width of the border.
  2. Border-style: The border style is the value that is given to the border property to specify the style of the border. Various border style values are given below:
    • Solid: It specifies a solid border.
    • Dotted: It specifies a dotted border.
    • Double: It specifies a double border.
    • Dashed: It specifies a dashed border.
    • Ridge: It specifies a 3D ridged border.
    • Groove: It specifies a 3D grooved border.
    • Outset: It specifies a 3D outset border.
    • Inset: It specifies a 3D inset border.
    • Hidden: It specifies a hidden border.
    • None: It specifies a no border.
  3. Border color: The border color is the value that is given to the border property to specify the color of the borders.

Demonstration of the CSS Border

We will comprehend the CSS border property with the help of demonstrations.

Demonstration 1:

We will create a border on the <div> element in this demonstration utilizing the CSS border property.

Code:

Output:

Here is the output where we can clearly witness a solid border of 2px around the <div> element.

CSS Transparent Border

Demonstration 2:

We will create different styles of border in various elements in this demonstration utilizing the CSS border property.

Code:

Output:

Here is the output where we can clearly witness different styles of borders around the HTML elements.

CSS Transparent Border

Transparent Border

The transparent border is the border that is there around the element, but it is invisible. Only the background can be seen instead of the border.

There is no particular property of transparent border but we can create a transparent border with the help of rgba or putting the value of color as transparent.

Syntax when using "transparent" value in place of color:

The value "transparent" is used in the place of border color in the above-provided syntax.

Syntax when using the "rgba" value in place of color:

The value "rgba" is used in the place of border color in the above-provided syntax. The rgba contains four values, which are described below:

  • Value 1: It is utilized to give the red color from 0% to 100% or 0 to 255.
  • Value 2: It is utilized to give the green color from 0% to 100% or 0 to 255.
  • Value 3: It is utilized to give the blue color from 0% to 100% or 0 to 255.
  • Value 4: It is an alpha parameter utilized to give transparency from 0 to 1.0. If the value of alpha is 0, then it is fully transparent. If the value of alpha is 1.0, then it is fully opaque.

Mostly, the rgba value is utilized when the image border or text border is created.

Demonstrations of the CSS Transparent Border

Now, we will comprehend the CSS transparent border with the help of demonstrations.

Demonstration 1:

We will create a transparent border on the <div> element in this demonstration utilizing the CSS border property and giving the value of color as transparent.

Code:

Output:

Here is the output where we can clearly witness a transparent border around the HTML element.

CSS Transparent Border

Demonstration 2:

In this demonstration, we will create a transparent border by utilizing the CSS border property and giving the color value in RGBA.

Code:

Output:

Here is the output where we can clearly witness a transparent border on the <div> element.

CSS Transparent Border

Demonstration 3:

In this demonstration, we will create an image border using the CSS border property and give the color value in RGBA.

Code:

Output:

Here is the output where we can clearly witness an image border.

CSS Transparent Border

Browser Support

Following are the browsers that support the CSS border property:

  • Google Chrome
  • Opera
  • Microsoft Edge
  • Safari
  • Firefox

Conclusion

We have understood how to construct the CSS transparent border in this article with the help of various demonstrations. We can utilize the transparent keyword or rgba value to create the transparent 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